可以先更换命令执行,查看详细报错:
我先是
dcp@localhost send]$ ./test_db_connection.sh执行,只报:Text file busy
然后使用 lsof
命令来查找占用文件的进程,但是长时间没反应,查看权限之后也没问题
运行脚本时使用 bash
命令就出现了更为详细的错误问题:
[root@localhost send]# bash db_test.sh db_test.sh: line 2: $'\r': command not found db_test.sh: line 9: $'\r': command not found db_test.sh: line 11: mysql: command not found db_test.sh: line 12: $'\r': command not found db_test.sh: line 18: syntax error near unexpected token `fi' db_test.sh: line 18: `fi'
使用 sed
命令:将脚本文件中的 Windows 格式换行符替换为 Unix 格式换行:
sed -i 's/\r$//' db_test.sh
格式就没问题了