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