我正在学习shell脚本!同样我尝试在ubuntu终端上使用curl下载facebook页面.
t.sh内容
vi@vi-Dell-7537(Desktop) $cat t.sh
curlCmd="curl \"https://www.facebook.com/vivekkumar27june88\""
echo $curlCmd
($curlCmd) > ~/Desktop/fb.html
运行脚本时出错
vi@vi-Dell-7537(Desktop) $./t.sh
curl "https://www.facebook.com/vivekkumar27june88"
curl: (1) Protocol "https not supported or disabled in libcurl
但是如果直接运行命令那么它工作正常.
vi@vi-Dell-7537(Desktop) $curl "https://www.facebook.com/vivekkumar27june88"
Meta chars.....
如果有人让我知道我在剧本中所犯的错误,我将不胜感激.
我已经验证了curl库启用了ssl.
最佳答案
嵌套在括号内的命令作为子shell运行,因此您的环境变量将丢失.
原文链接:/linux/440538.html试试eval:
curlCmd="curl 'https://www.facebook.com/vivekkumar27june88' > ~/Desktop/fb.html"
eval $curlCmd