简体   繁体   English

在Debian 7上运行bash脚本时选项无效

[英]Invalid option when running bash script on Debian 7

When I run 我跑的时候

root@Nano:/etc/init.d# ./utserver

which is this script http://pastebin.com/c7gxFdci it gives me this output 这个脚本是http://pastebin.com/c7gxFdci,它给了我这个输出

": invalid option" 

no matter how the arguments are done. 无论论证如何完成。

Your file has DOS \\r\\n line endings. 您的文件有DOS \\r\\n行结尾。 Here's the relevant section from the bash tag wiki : 这是bash标签wiki的相关部分:

  1. Check whether your script or data has DOS style end-of-line characters 检查脚本或数据是否具有DOS样式的行尾字符

    • Use cat -v yourfile or echo "$yourvariable" | cat -v 使用cat -v yourfileecho "$yourvariable" | cat -v echo "$yourvariable" | cat -v . echo "$yourvariable" | cat -v

      DOS carriage returns will show up as ^M after each line. DOS回车将在每行后显示为^M

      If you find them, delete them using dos2unix (aka fromdos ) or tr -d '\\r' 如果找到它们,请使用dos2unix (也称为fromdos )或tr -d '\\r'删除它们

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

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