[英]CURL: empty file in bash script
If i run this command in linux command line manually it works, and EDIT.3126026369 is not empty 如果我在linux命令行中手动运行此命令,它将起作用,并且EDIT.3126026369不为空
curl "http://somesite.com/admin.php?mod=editnews&action=editnews&id=14058" -s -L -b cookie.ck -c cookie.ck > EDIT.3126026369
in bash: 在bash中:
curl \"$EDIT\" -s -L -b $COOKIE -c $COOKIE > EDIT.$TEMP
but in a bash script it generate an empty file. 但是在bash脚本中会生成一个空文件。 what am missing here?
这里缺少什么?
Use the quotes when defining your $EDIT variable: 定义$ EDIT变量时,请使用引号:
EDIT="http://somesite.com/admin.php?mod=editnews&action=editnews&id=14058"
Then lose the escaped quotes on the curl command: 然后在curl命令上丢失转义的引号:
curl $EDIT -s -L -b $COOKIE -c $COOKIE > EDIT.$TEMP
Seems to work fine for me this way, how about you? 这样看来对我来说很好,那你呢?
What's in your $EDIT
variable, and do you need to quote it like that? 您的
$EDIT
变量中有什么,您是否需要像这样引用它? If it's your URL, I would simply expect you to write 如果是您的网址,我只是希望您写
curl $EDIT ....
If you run your bash script with a -x
option, it'll show you each line that it executes. 如果使用
-x
选项运行bash脚本,它将显示执行的每一行。 That's a very useful debugging technique. 这是非常有用的调试技术。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.