我嘗試使用shell腳本中shell變量可以使用,我的shell腳本如下一個shell腳本中設置變量之外的下一個命令
HerculesResponse=$(curl -X POST -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{ "testID": "591dc3cc4d5c8100054cc30b", "testName": "stagetest", "poolID": "5818baa1e4b0c84637ce36b4", "poolName": "Default", "dashboardID": "582e3a2ff5c650000124c18a", "dashboardName": "Default", "dateCreated": "2017-05-23T13:51:23.558Z", "callbackHeader": {}, "active": true }' "https://example.com:8080/run")
reportURL=$(expr "$HerculesResponse" : '.*"reportURL":"\([^"]*\)"') echo $reportURL runId=$(echo $reportURL | cut -d"=" -f 2) echo $runId
我如何使用的runid變量此shell腳本之外運行的命令
testStatus=$(curl -X GET https://example.com:8080/runs/$runId)
我試圖用出口的runid命令但不起作用
'export'使變量可用*子*進程 - 也就是說,流程以後開始。它不會使它們可用於* parent *進程(即啓動您的進程)。 –