loops - Fix ssh line for Xpra bash script -


im writting small script starting 'xpra' session remote machine. i'm pretty new bash scripting, wondering if me clean code bit, concerning best practices.

the ssh line 1 i'm having problems with, must ctrl-c on keyboard command killed , let continue echo "done".

how can fix minor issue?

    ###                                         ###     #       syntax: xpra.sh hostmachine command   #     ##                                          ###      ## wake on lan host machine.     ~/scripts/$1      ## check if online , ssh command.     ## attach xpra client.     while :;         ping -c 1 $1         if [ $? -eq 0 ];             ssh $1 "xpra start :7 && sleep 2 && ("display=:7 $2"&) ";             echo "done";             sleep 5;             echo "attaching";             (xpra attach ssh:$1:7 &);             break;         else                 echo "host offline";             sleep 180s;         fi     done 

newer versions support starting remote sessions in 1 command, try:

xpra start ssh:host:display --start-child=xterm 

this will

  • start new remote session on display display
  • start xterm in it
  • then connect client session

it's lot cleaner script relies on "sleep"...


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -