打开screen并运行一些项目和应用程序

打开screen并运行一些项目和应用程序

我是一名 Python Web 开发人员,我需要在screen会话中运行本地的 3-4 个 Django 项目,并且需要启动一些应用程序,例如skypechromeeclipse文本文件daily status.txt。有没有办法编写一个脚本,仅通过运行 shell 脚本即可启动所有这些应用程序?

   #!/bin/bash
   # 
   gnome-terminal -e "screen -dmS myapps"

   #(Attach following command to one of the screen)
   cd /var/opt/project1
   python manage.py runserver 127.0.0.1:8001 

   #(Attach another command to one of the screen)
   cd /var/opt/project2
   python manage.py runserver 127.0.0.1:8002

   #(Attach another command to one of the screen)
   cd /var/opt/project3
   python manage.py runserver 127.0.0.1:8003

   #start my applications
   eclipse
   skype
   gedit "/home/myname/Desktop/daily status.txt"
   [...]    

有人可以帮我编写一个 shell 脚本来执行此操作吗?

答案1

您可以执行以下操作

screen -S "DjangoRunservers" -d -m

#Do this if you don't want the first screen window to be blank
#screen -S "DjangoRunservers" -X stuff 'python /var/opt/project1/manage.py runserver 127.0.0.1:8001^M'
#Note: You get ^M by hitting Ctrl-V and the Return

screen -S "DjangoRunservers" -X screen python /var/opt/project1/manage.py runserver 127.0.0.1:8001
screen -S "DjangoRunservers" -X screen python /var/opt/project2/manage.py runserver 127.0.0.1:8002
screen -S "DjangoRunservers" -X screen python /var/opt/project3/manage.py runserver 127.0.0.1:8003

在独立的屏幕中启动 python 服务器。

在我的 Mac 上,要从终端运行 eclipse,我必须这样做

/Applications/eclipse/eclipse

我猜 Skype 也是同样的情况。

相关内容