简体   繁体   English

Raspbian:从.sh文件启动程序

[英]Raspbian: start program from .sh file

I want to do this: 我想做这个:

  • Execute an executable from a .sh file 从.sh文件执行可执行文件
  • Keep this executable open in terminal 保持此可执行文件在终端中打开

I tried to write a .sh file with "./program" but "program" closes automatically after flashing a console, but I want that terminal to keep open! 我试图用“ ./program”编写一个.sh文件,但是在刷新控制台后“ program”会自动关闭,但是我希望该终端保持打开状态!

I assume you are in a graphical environment, and want to execute a script by double-clicking the ".sh" file, then keep the terminal window open to see any result. 我假设您处于图形环境中,并且想要通过双击“ .sh”文件来执行脚本,然后保持终端窗口打开以查看任何结果。

At the end of your script, add something like this : 在脚本末尾,添加以下内容:

echo "Hit the [return] key to exit"
read

This will cause execution to pause until you hit [return]. 这将导致执行暂停,直到您按下[return]。

Note : you cannot keep a program running when it has finished executing. 注意:程序执行完毕后,将无法继续运行。 So the program you are calling from your script finishes, but then you give the terminal (which is also a program) something to do (waiting for input) to prevent it from closing. 这样,您从脚本中调用的程序就完成了,但是然后您给终端(也是程序)做点事(等待输入)以防止其关闭。

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

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