取Curl的输出并发送到第二个curl命令

时间:2012-11-12 01:26:31

标签: shell variables curl grep

curl -s http://meet97263421.adobeconnect.com/api/xml?action=common-info | \
grep -oP '(?<=<cookie>).*?(?=</cookie>)|(?<=account-id=").*?(?=")' 2>&1\

上面的curl / grep命令返回以下数据:

na3breezswp8yf3s5fghdgn4
1013353222

如何将这两个输出发送到第二个curl命令:

curl "https://meet97263421.adobeconnect.com/api/xml?\
action=login&login=USERNAME&password=PASSWORD&account-id=[$1]&session=[$0]"

我正在使用[$1][$0]作为占位符。

1 个答案:

答案 0 :(得分:1)

也许这有帮助:

#!/bin/bash

OUT=$(curl -s http://meet97263421.adobeconnect.com/api/xml?action=common-info \
| grep -oP '(?<=<cookie>).*?(?=</cookie>)|(?<=account-id=").*?(?=")')

# echo $OUT && echo 

Session=$(cut -f1 -d' ' <<< $OUT)
AccountID=$(cut -f2 -d' ' <<< $OUT)

curl "https://meet97263421.adobeconnect.com/api/xml?action=login&login=USERNAME&password=PASSWORD&account-id=$AccountID&session=$Session"

# or 

curl "https://meet97263421.adobeconnect.com/api/xml?action=login&login=USERNAME&password=PASSWORD&account-id=`cut -f2 -d' ' <<< $OUT`&session=`cut -f1 -d' ' <<< $OUT`"