简体   繁体   English

在 shell 脚本中执行 curl 时找不到命令

[英]Command not found while executing curl in shell script

I am executing the below curl command in shell script.我正在 shell 脚本中执行以下 curl 命令。 But I am getting command not found error.但我收到命令未找到错误。 So wanted to check if I am making any mistake while executing it.所以想检查我在执行它时是否犯了任何错误。

return = $(curl -s --location --request GET --url 'https://testurl.mywebsite.com/api/accts?Id=trst_id&var=test_var' --header 'type: app/test')

echo "data is: ${return}"

I am getting the error:我收到错误消息:

return: command not found

Kindly let me know if there is a problem with the way I am trying to execute the curl command.如果我尝试执行 curl 命令的方式有问题,请告诉我。

Thank you.谢谢你。

Like dan pointed out in comments, the extra whotespaces between the variable and command caused the issue.就像 dan 在评论中指出的那样,变量和命令之间的额外空格导致了这个问题。 After removing extra whitespaces it worked.删除多余的空格后,它起作用了。

return=$(curl -s --location --request GET --url 'https://testurl.mywebsite.com/api/accts?Id=trst_id&var=test_var' --header 'type: app/test') echo "data is: ${return}" return=$(curl -s --location --request GET --url 'https://testurl.mywebsite.com/api/accts?Id=trst_id&var=test_var' --header 'type: app/test') echo “数据是:${return}”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM