英文:
How to run .sh file from console
问题
我想知道为什么无法通过 ./launch.sh
运行 .sh
文件,请查看以下发布的屏幕截图:
图像
英文:
I would like to know why I can not run the .sh
file via ./launch.sh
please have a look at the below posted screen-shot
image
答案1
得分: 2
你需要使用chmod +x launch.sh
将其标记为可执行程序,或者可以使用bash执行它:bash launch.sh
。
英文:
You need to mark it as an executable program with chmod +x launch.sh
, or alternatively execute it with bash: bash launch.sh
答案2
得分: 0
The command "sh launch.sh" would be 这个命令应该是 "sh launch.sh"。
英文:
I think the command would be sh launch.sh
答案3
得分: 0
@Wouter De Coster 解决了问题,不过我将尝试添加更多信息。
控制台方法
设置区域
要使用 ./
函数,文件必须具有脚本的执行权限。
使用 chmod +x launch.sh
来设置这些权限。
运行区域
再次尝试使用 ./launch.sh
。
还有其他执行它们的选项:
sh launch.sh
bash launch.sh
图形用户界面方法
设置区域
- 使用鼠标选择文件
- 在文件上右键单击
- 选择属性
- 点击 权限 选项卡
- 选择允许将文件作为程序执行:
运行区域
单击文件名,将出现提示。选择在终端中运行,并它将在终端中执行。
一旦更改了属性,您可以使用控制台方法中使用的运行方法。
额外信息
您可以运行 .sh 文件并使用调试选项,例如:
要调试 shell 脚本,它会显示执行命令及其参数。
bash -x launch.sh
要显示 shell 输入行,按照它们被读取:
bash -v launch.sh
英文:
@Wouter De Coster solve the problem, anyway i´ll try to add a bit more information.
Console Method
Setting Area
To use ./
function, the file must have execute permission on the script.
use chmod +x launch.sh
to set that permissions.
Run Area
Try to use ./launch.sh
again.
Another options to execute them:
sh launch.sh
bash launch.sh
GUI Method
Setting Area
- Select the file using mouse
- Right-click on the file
- Choose properties
- Click Permissions tab
- Select Allow executing file as a program:
Run Area
Click the file name and you will be prompted. Select Run in the terminal
and it will get executed in the terminal.
Once you changed the properties you can use the Run methods used in Console Method
#EXTRA
You can run .sh file and use debugging options, For example:
To debug shell script. It print commands and their arguments as they are executed.
bash -x launch.sh
To show shell input lines as they are read:
bash -v launch.sh
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论