简体   繁体   English

执行shell脚本

[英]issue executing shell script

I'm having a strange issue when I try and execute a shell script. 尝试执行Shell脚本时遇到一个奇怪的问题。

when I try to execute the script with ./scriptname.sh it just immediately returns to the prompt. 当我尝试使用./scriptname.sh执行脚本时,它会立即返回提示。 The script has the correct permissions set. 该脚本具有正确的权限集。 If I copy the script to another server it executes no problem at all. 如果我将脚本复制到另一台服务器,它将完全没有问题。

I can execute other sh scripts on the server in question with no problem. 我可以毫无问题地在服务器上执行其他sh脚本。

is there a way of troubleshooting this as I am at a loss? 我不知所措,有什么方法可以解决此问题?

Thanks in advance. 提前致谢。

Best way to check the syntax errors, you can do the below. 检查语法错误的最佳方法,您可以执行以下操作。

sh -n script_name sh -n script_name

If you wanted to execute the script and see the flow you can use the below 如果要执行脚本并查看流程,可以使用以下内容

sh -x script_name sh -x script_name

Hope it helps 希望能帮助到你

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

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