2017-04-21 57 views
0

我需要將curl url格式化爲這樣才能成功。在bash中創建捲曲URL

$instanceUrl/sobjects/$sObject/describe -H 'Authorization: Bearer $apiToken' 

這是我的腳本到目前爲止。

#!/bin/bash 
CURL='/usr/bin/curl' 
CURLARGS='-H' 

echo "welcome to sf-db-mock" 

echo "please enter the instance url of the Salesforce org database you'd like to mock, followed by [ENTER]:" 

# get rest endpoint 
read instanceUrl 

echo "please enter your api token, followed by [ENTER]:" 

# get api token from users current session 
read apiToken 

# get the objects the users wants described 
echo "please enter each sObject you'd like to mock by entering its API Name, using a space after each sObject, followed by [ENTER]:" 

read -a sObjects 

for sObject in ${sObjects[@]} 

do 
    describe="$('sobjects'\/$sObject\/'describe '$CURLARGS ' Authorization: Bearer '$apiToken)" 
    echo $instanceUrl$describe 
done 

我得到的同時運行它的錯誤是

./mock.txt:第25行:sobjects /調查/描述-H:沒有這樣的文件或目錄」

我的bash腳本是可執行的。

回答

0

符號$(a b c)表示運行命令a,其參數爲bc

你需要的是刪除括號:

describe="sobjects/$sObject/describe $CURLARGS 'Authorization: Bearer '$apiToken'"