运行.sh文件从控制台

huangapple go评论75阅读模式
英文:

How to run .sh file from console

问题

我想知道为什么无法通过 ./launch.sh 运行 .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

运行.sh文件从控制台

答案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

图形用户界面方法

设置区域

  1. 使用鼠标选择文件
  2. 在文件上右键单击
  3. 选择属性

运行.sh文件从控制台

  1. 点击 权限 选项卡
  2. 选择允许将文件作为程序执行:

运行.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

  1. Select the file using mouse
  2. Right-click on the file
  3. Choose properties

运行.sh文件从控制台

  1. Click Permissions tab
  2. Select Allow executing file as a program:

运行.sh文件从控制台

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

huangapple
  • 本文由 发表于 2023年3月9日 18:10:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/75683130.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定