Custom script in .screenrc
        Posted  
        
            by benoror
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by benoror
        
        
        
        Published on 2010-03-03T17:36:51Z
        Indexed on 
            2010/04/05
            20:03 UTC
        
        
        Read the original article
        Hit count: 327
        
Hi. 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 <[email protected]>
#
# 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 ?
© Stack Overflow or respective owner