bash 在 IBM AIX 中运行 Shell 脚本需要帮助

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9516101/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 01:42:03  来源:igfitidea点击:

Need Help Running a Shell Script in IBM AIX

bashaix

提问by user66854

we have a shell script which we are trying to run as $>./shell.sh. On running this we get a error about a "bad interpreter". on running the script as sh shell.shit runs. my question is can we run a shell script in IBM AIX as ./shell.sh.

我们有一个 shell 脚本,我们试图将其作为$>./shell.sh. 在运行它时,我们会收到关于“错误解释器”的错误。在运行脚本sh shell.sh时运行。我的问题是我们可以在 IBM AIX 中运行一个 shell 脚本作为./shell.sh.

we have a lot of shell scripts which call other scripts. changing the shell scripts to call the other shell scripts as sh other_shell_scripts.shis not feasible.

我们有很多调用其他脚本的 shell 脚本。更改 shell 脚本以调用其他 shell 脚本sh other_shell_scripts.sh是不可行的。

note we are using the bash shell as the default shell

请注意,我们使用 bash shell 作为默认 shell

回答by l0b0

If you want to run a script with ./shell.shit musthave a shebang lineas the first line, for example #!/usr/bin/env bashor #!/bin/sh.

如果你想用./shell.sh它运行一个脚本必须有一个shebang行作为第一行,例如#!/usr/bin/env bash#!/bin/sh

If you do have a shebang line, check that it's correctly formatted and that your files do not contain DOS newlines (\r\n, aka CRLF). You can use dos2unixto fix such files.

如果您确实有 shebang 行,请检查它的格式是否正确以及您的文件是否不包含 DOS 换行符(\r\n, aka CRLF)。您可以使用dos2unix来修复此类文件。