Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can please someone help me to make script for multi screen command at startup

here is what it is

cd /home/bhop1/serverfiles
screen ./srcds_run -console -game cstrike -tickrate 100 -pingboost 2 +map bhop_eazy -maxplayers 32 -port 27015
cd /home/mg/serverfiles
screen ./srcds_run -console -game cstrike -tickrate 100 -pingboost 2 +map mg_100traps_v3 -maxplayers 32 -port 27016
screen ./srcds_run -console -game cstrike -pingboost 2 +map de_dust2 -maxplayers 32 -port 27017
cd /home/caln3/serverfiles
screen ./srcds_run -console -game cstrike -pingboost 2 +map de_dust2 -maxplayers 32 -port 27018
cd /home/clan1/serverfiles
screen ./srcds_run -console -game cstrike -pingboost 2 +map de_dust2 -maxplayers 32 -port 27019
cd /home/clan2/serverfiles
screen ./srcds_run -console -game cstrike -pingboost 2 +map ze_minecraft_v1 -maxplayers 32 -port 27020
cd /home/ze/serverfiles
screen ./srcds_run -console -game cstrike -pingboost 2 +map zm_cbble_b4_5 -maxplayers 32 -port 27021
cd /home/zm/serverfiles


is there something wrong?

# !/bin/bash
alias cdproj="cd /home/bhop1/serverfiles"
screen -dmS bhop ./srcds_run -console -game cstrike -tickrate 100 -pingboost 2 +map bhop_eazy -maxplayers 32 -port 27015
alias cdproj="cd /home/mg/serverfiles"
screen -dmS MG ./srcds_run -console -game cstrike -tickrate 100 -pingboost 2 +map mg_100traps_v3 -maxplayers 32 -port 27016
alias cdproj="cd /home/caln3/serverfiles"
screen -dmS clan1 ./srcds_run -console -game cstrike -pingboost 2 +map de_dust2 -maxplayers 32 -port 27017
alias cdproj="cd /home/clan1/serverfiles"
screen -dmS clan2 ./srcds_run -console -game cstrike -pingboost 2 +map de_dust2 -maxplayers 32 -port 27018
alias cdproj="cd /home/clan2/serverfiles"
screen -dmS clan3 ./srcds_run -console -game cstrike -pingboost 2 +map de_dust2 -maxplayers 32 -port 27019
alias cdproj="cd /home/ze/serverfiles"
screen -dmS ZE ./srcds_run -console -game cstrike -pingboost 2 +map ze_minecraft_v1_1 -maxplayers 32 -port 27020
alias cdproj="cd /home/zm/serverfiles"
screen -dmS -ZM ./srcds_run -console -game cstrike -pingboost 2 +map zm_cbble_b4_5 -maxplayers 32 -port 27021
share|improve this question

closed as off-topic by Ƭᴇcʜιᴇ007, Breakthrough, Xavierjazz, mpy, Jens Erat Jul 1 '14 at 17:24

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question is not about computer hardware or software, within the scope defined in the help center." – Breakthrough, mpy, Jens Erat
If this question can be reworded to fit the rules in the help center, please edit the question.

What exactly do you need help doing? – slow_excellence Jul 1 '14 at 15:27
SU is not a scripting service. Rephrase your question to be like "I'm trying to do X, here's my script Y, but it's giving me error Z" – Wutnaut Jul 1 '14 at 15:37
up vote 0 down vote accepted

From man screen:

-dmS name Start as daemon: Screen session in detached mode.
-r        Reattach to a detached screen process.

So you can start every command in its own screen daemon with a name, for example:

screen -dmS port27015 ./srcds_run -console -game cstrike -tickrate 100 -pingboost 2 +map bhop_eazy -maxplayers 32 -port 27015

Now you can resume this screen using:

screen -r port27015

I think this is what you're looking for. Just make sure you use an unique name for every screen daemon, because otherwise screen won't be able to know which screen you want to reattach.

Note: you should use CTRL + A + D to detach a screen. Any other key combination or command will probably just kill the screen and the process running inside it.

share|improve this answer
Thanks for replaying but when i run the script it give me ": No such file or directoryash : No such file or directoryme/bhop1/serverfiles : No such file or directoryme/mg/serverfiles : No such file or directoryme/caln3/serverfiles : No such file or directoryme/clan1/serverfiles : No such file or directoryome/clan2/serverfiles : No such file or directoryome/ze/serverfiles : No such file or directoryome/zm/serverfiles " – user3599148 Jul 1 '14 at 17:25
Of course you should only cd to directories that exist. Check if you got the path right. Otherwise open a new question as this has nothing to do with this question. – Louis Matthijssen Jul 1 '14 at 17:34
i tried to put alias cdproj="cd /home/zm/serverfiles" and it worked but i can see any screen there when i try to use screen -r – user3599148 Jul 1 '14 at 18:56
It should work. Try using screen -dmS test top and then screen -r test to see if screen is working. If it's working something is wrong with your command (if your command fails/exits screen will terminate). Try to execute your command without screen to see what's wrong. – Louis Matthijssen Jul 1 '14 at 19:02

Not the answer you're looking for? Browse other questions tagged .