运行bash脚本时自动打开终端

[英]Automatically open terminal when running bash script


To get the script to run in terminal, I have to select the option to open in terminal and write sh script name.shIs there a way I can reduce that to a single step, i.e. a launcher that automatically opens the script in a terminal after logging as a root ? I've tried to look it up on Google, but I haven't found any useful advice (perhaps I'm not executing the search properly).

为了让脚本在终端中运行,我必须选择在终端中打开的选项并写入sh脚本名称。这是一种我可以将其减少到一个步骤的方法,即一个在终端后自动打开脚本的启动器以root身份登录?我试图在谷歌上查找,但我没有找到任何有用的建议(也许我没有正确执行搜索)。

1 个解决方案

#1


1  

I think what you mean is running your script as start up script. In that case place the script you want to run in the /etc/init.d directory and make the script executable with command chmod 755 scriptname.sh.

我认为你的意思是将脚本作为启动脚本运行。在这种情况下,将要运行的脚本放在/etc/init.d目录中,并使用命令chmod 755 scriptname.sh使脚本可执行。

See the below related threads for more information

有关更多信息,请参阅以下相关线程

https://askubuntu.com/questions/290099/how-to-run-a-script-during-boot-as-root

https://askubuntu.com/questions/290099/how-to-run-a-script-during-boot-as-root

How to run a shell script at startup

如何在启动时运行shell脚本

EDIT:

编辑:

if you want to run your script after your login is successful then you need to place your script in ~/.bash_profile. See this related post

如果要在登录成功后运行脚本,则需要将脚本放在〜/ .bash_profile中。看到这篇相关的帖子

How do you run a script on login in *nix?

如何在* nix中登录时运行脚本?


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2014/03/29/e73e0ffb84b1f94201b85e4eb68b4e36.html



 
粤ICP备14056181号  © 2014-2020 ITdaan.com