【发布时间】:2023-03-18 11:42:01
【问题描述】:
我正在尝试在 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
如何在这个 shell 脚本之外使用 runId 变量来运行命令
testStatus=$(curl -X GET https://example.com:8080/runs/$runId)
我尝试使用 export runId 命令但不起作用
【问题讨论】:
-
export使变量可用于 子 进程 - 即您稍后启动的进程。它不会使它们可用于 父 进程(即启动您的进程)。
标签: shell