Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
not FOUNKSH:2:在shell命令中执行时出错?_Shell - Fatal编程技术网

not FOUNKSH:2:在shell命令中执行时出错?

not FOUNKSH:2:在shell命令中执行时出错?,shell,Shell,当我运行sh backuptest.sh时,会出现以下错误。代码或shell是否有问题 result : : not foundsh: 2: backuptest.sh: : not foundsh: 4: backuptest.sh: : not foundsh: 6: backuptest.sh: : not foundsh: 7: backuptest.sh: content of backuptest.sh #!/bin/sh -e location=`date +%Y%m%d`.

当我运行sh backuptest.sh时,会出现以下错误。代码或shell是否有问题

result :
: not foundsh: 2: backuptest.sh:
: not foundsh: 4: backuptest.sh:
: not foundsh: 6: backuptest.sh:
: not foundsh: 7: backuptest.sh:



content of backuptest.sh
#!/bin/sh -e
location=`date +%Y%m%d`.sql
mysqldump -u root -proot spider_db > $location
删除
#/bin/sh-e
并重试

dos2unix backuptest.sh
然后再次执行

./backuptest.sh

ls/bin/sh行吗?看起来您的脚本包含DOS样式的行尾。试试
dos2unix
@glennjackman,你这个传奇人物!