[英]reading parameters into cURL from a text file in bash
我有以下cURL命令在Jenkins中執行soapui測試。 我在這里傳遞了兩個參數variable1和variable2。
curl --form "project=/build.tool/.jenkins/jobs/$variable1" --form "suite=$variable2" host
我有一個以下.txt文件,其中這些變量的值在兩列中以空格分隔。 如何在cURL命令中遍歷所有這些值?
#file1.txt
project1.xml TestSuite_1
project1.xml TestSuite_2
project2.xml TestSuite_3
project2.xml TestSuite_4
project3.xml TestSuite_5
在您的測試輸入上使用了這個
while read p; do
var1=`echo $p | awk '{print $1" "}'`
var2=`echo $p | awk '{ print " "$2}'`
echo $var1
echo $var2
done <infile
infile包含您的數據的位置。
輸出:
project1.xml
TestSuite_1
project1.xml
TestSuite_2
project2.xml
TestSuite_3
project2.xml
TestSuite_4
project3.xml
TestSuite_5
現在,您已經將它們存儲在變量中,您可以將它們添加到curl
命令中
curl --form "project=/build.tool/.jenkins/jobs/$var1" --form "suite=$var2" host
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.