我遇到两个问题,其原因可能相同,这就是为什么我将它们发布在一个问题中。
这是我的小shell脚本:
#!/bin/bash
wget "https://phantomjs.googlecode.com/files/phantomjs-1.9.2-linux-i686.tar.bz2"
然后我说./script
。
我懂了 bash: ././script: /bin/bash^M: bad interpreter: No such file or directory
然后我对自己说,好的,尝试bash script
代替./script
。
看来可行,但是URL如下:
--2013-12-31 12:24:55-- https://phantomjs.googlecode.com/files/phantomjs-1.9.2-
linux-i686.tar.bz2%0D
Resolving phantomjs.googlecode.com... 173.194.69.82, 2a00:1450:4008:c01::52
Connecting to phantomjs.googlecode.com|173.194.69.82|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2013-12-31 12:25:01 ERROR 404: Not Found.
您是否知道我的URL2%0D
在文件名后的第2行中添加了?
当我在shell本身而不是脚本中运行命令时,它完全可以正常工作。
这两个问题的根源是否相同?为什么会有2%0D
附件?我已经在寻找空白空间,但是没有找到它。
您可能使用创建DOS行尾(\ r \ n)的编辑器来编辑脚本。使用其他编辑器或使用类似的工具将其转换dos2unix
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句