[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Screen Start Script
Screen Start Script
Sun, 9 Jul 2006 13:10:34 -0700 (PDT)
I have yet to find an example online that actually shows how to start
windows in a straight forward way. Actually, I have not been able to find
sort of straight forward way. But I thought I would post my solution to
problem and ask for advice on better ways to do this.
I basically use screen to be logged into several systems at once for
parts of my company's network. On occasion something makes screen freeze
(im thinking its irssi) so I end up killing all the sessions and doing
them all over again. This happened a few too many times in one day, so I
decided to make a script out of it.
My first attempts were just to launch a normal screen just like I would
typing on the command line;
screen ssh sever1
screen ssh server2 ... etc
But of course you would have to pass arguments to the newly created bash
shell you started screen with, and that left me in an odd state of trying
to do things like;
screen bash & screen ssh server1 & screen ssh server2, etc...
That wasn't going to work either (yeah, im still a bit green on this
because it was backgrounding the other processes ( i think?)
Then I thought, ummmm... maybe a case statement would work?
Gave this a shot;
case "$1B" in
start ) screen bash & setscreen.sh phase2 ;;
phase2 ) screen -t SV1 3 "ssh server1"
screen -t SV2 4 "ssh server2"
screen -t IRC 1 "irssi" ;;
Somehow this kind of worked, but not quite right. Screen would do some
weird word wrapping, and the terminal was basically unusable.
What has actually worked is this, and I think it sucks, but it does work
how I want it too:
I made one script, with two config files that bash can call from
--init-file, basically reparsing commands after I got into a new shell.
Only I really hate having more than one file for a simple purpose, I had
to create three:
#See if ssh-agent is running:
if [ -z "$SSH_AGENT_PID" ]
eval `ssh-agent bash --init-file ~/bin/add-key.rc` > /dev/null 2>
echo "Your already running ssh-agent!"
add-key.rc: Used to just get the ssh-add command off and call screen
screen bash --init-file ~/bin/screen-start.rc
screen-start.rc: Execute all the screen's with title names
screen -t Sev1 2 ssh server1
screen -t Sev2 3 ssh server2
screen -t Sev3 4 ssh server3
screen -t IRC 1 irssi
And this would in sum load my ssh-agent bash, ssh-add, then open up all
screen sessions with proper titles and not have to enter my password more
than once. Of course if you always load your ssh-agent, you can skip that
Please tell me someone has a better solution to this sort of situation.
some cool way to start new screens inside of a detached session? Some way
making sure they spawn from the first bash shell with ssh-keys already
Or am I just crazy ? :-)
- Screen Start Script,