You are not logged in.

#1 2010-03-03 17:33:29

benoror
Member
Registered: 2009-07-20
Posts: 66
Website

Custom script in .screenrc

Hi archers. I made a script that spawns a remote shell or runs a local shell whether it's on the current machine or not:

#!/bin/bash
# By:  benoror <benoror@gmail.com>
#
# spawns a remote shell or runs a local shell whether it's on the current machine or not
# $1 = hostname

if [ "$(hostname)" == "$1" ]; then
    bash
else
    ssh "$1.local"
fi

For example, if I'm on server1:

./spawnshell.sh server1   -> runs bash
./spawnshell.sh server2   -> ssh to server2.local

I want that script to run automatically in separate tabs in GNU Screen, but I can't make it run, my .screenrc:

...
screen -t "@server1"  1   exec /home/benoror/scripts/spawnshell.sh server1
screen -t "@server2"  2   exec /home/benoror/scripts/spawnshell.sh server2
...

But it doesn't works, I've tried without 'exec', with -X option and a lot more. Any ideas ?

Last edited by benoror (2010-03-03 17:34:39)


ArchLinux :: Awesome WM :: dotfiles

Offline

#2 2010-03-03 17:37:19

Daenyth
Forum Fellow
From: Boston, MA
Registered: 2008-02-24
Posts: 1,244

Re: Custom script in .screenrc

Does foo.local resolve correctly by hand? Try nslookup server2.local

Offline

#3 2010-03-03 17:39:02

benoror
Member
Registered: 2009-07-20
Posts: 66
Website

Re: Custom script in .screenrc

It does, I configured domains lookups with Avahi (http://wiki.archlinux.org/index.php/Avahi)


ArchLinux :: Awesome WM :: dotfiles

Offline

#4 2010-03-03 18:02:05

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,799
Website

Re: Custom script in .screenrc

benoror,

can you be a little more specific about "doesn't work".

does screen not load the two tabs?
does screen load the tabs, but not run the script(s)?
does screen load the tabs, run the script(s), but fail to connect?

(i don't think you need exec btw)

thanks,
pat

Offline

#5 2010-03-03 18:03:59

benoror
Member
Registered: 2009-07-20
Posts: 66
Website

Re: Custom script in .screenrc

Well, screen load the tabs, but doesn't run the scripts. Thanks.


ArchLinux :: Awesome WM :: dotfiles

Offline

#6 2010-03-03 18:13:42

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,799
Website

Re: Custom script in .screenrc

my -t lines only have two arguments [name] [command].

does this work:

screen -t server1 /home/benoror/scripts/spawnshell.sh server1
screen -t server2 /home/benoror/scripts/spawnshell.sh server2

and just to confirm, spawnshell.sh works fine when you run it outside of screen right?

Offline

#7 2010-03-03 18:20:04

benoror
Member
Registered: 2009-07-20
Posts: 66
Website

Re: Custom script in .screenrc

Solved.

Sorry, I forgot to chmod it as executable. I feel stupid hehe.

Thanks!


ArchLinux :: Awesome WM :: dotfiles

Offline

Board footer

Powered by FluxBB