创造一种全的bash后运行屏幕命令 [英] Run commands in screen after creating one per bash
本文介绍了创造一种全的bash后运行屏幕命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有应该创建一个屏幕以下的bash文件,去一个目录,然后启动节点脚本:
I have the following bash file which should create a screen, go to a directory and then start a node script:
screen -S shared // 1
cd /home/nodejsapp // 2
node start.js app.js // 3
问题是,执行1后,我确实看到屏幕共享,但2及3将执行previous终端上,而不是屏幕共享的。
The problem is, after executing 1, I indeed see the screen 'shared', but 2 & 3 will execute on the previous terminal, not on the screen 'shared'.
我怎样才能做到这一点命令2和3将当前屏幕上执行?
How can I achieve that commands 2 and 3 will be executed on the current screen?
推荐答案
您可以创建一个分离
屏幕,然后发送命令给它。例如:
You may create a detached
screen and then send commands to it. For example:
screen -d -m -S shared
screen -S shared -X -p 0 stuff $'cd /home/nodejsapp\n'
screen -S shared -X -p 0 stuff $'node start.js app.js\n'
如果您需要连接到屏幕
会议后,那么你可以添加更多行:
If you need to attach to the screen
session afterwards, then you can add one more line:
screen -S shared -r
请参阅的屏幕
手册详细信息:
- screen options
- screen commands
这篇关于创造一种全的bash后运行屏幕命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文