Register
It is currently Sun Nov 23, 2014 8:36 am

Wait for ssh tunnel to properly come up then launch program.


All times are UTC - 6 hours


Post new topic Reply to topic  [ 1 post ] 
Author Message
 PostPosted: Tue Nov 27, 2012 4:57 am   
User avatar

Joined: Sun Nov 01, 2009 8:59 am
Posts: 25
Location: Try to guess!
I've been using this old script for some time and almost forgot about it until the other day i became aware of its limitations. Because of the net slowing down to a crawl and the ssh handshake requiring almost 40 seconds to complete, i found out that it could not tell wether the ssh tunnel was ready or not. It could just simply detect (thanks to the ssh return value) wether ssh failed or not.
Code:
machine=mach001

if [[ $1 != "" ]]; then
   labmachine=$1
fi

echo "Connecting to: $labmachine"

ssh -2N $USER@$machine.my.domain.tld -L 1190:news.my.domain.tld:119 & sshpid=$!
retval=$?
if [[ $retval != 0 ]]; then
   notify-send -t 5 -i $iconfolder/messagebox_warning.png "SSH FAILED" "Exit code $retval"
   exit 1
fi
sleep 3
thunderbird
kill $sshpid
retval=$?
if [[ $retval != 0 ]]; then
   notify-send -t 5 "Kill failed."
   exit 1
fi

What's the proper way to make the script wait for the tunnel to be correctly established?
Using -v and grepping for "Entering interactive session"?? =))


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP