BashScripts.org
http://bashscripts.org/forum/

autorun script over ssh
http://bashscripts.org/forum/viewtopic.php?f=15&t=1365
Page 1 of 1

Author:  lush [ Fri Apr 29, 2011 9:55 am ]
Post subject:  autorun script over ssh

Hello,

I have many servers and I am writing a script which allows me to upload it to the servers and perform some instructions like to install a program, etc. I use something like:
Code:
{
sudo ssh -T $host <<-EOF
      wget -c $path/$file
      bash $file
EOF
} 2>/dev/null


Where 'file' is a shell code with the proper instructions. Is there any possibility to scp file to a server and run it automatically since it's been uploaded? This will simplify and speed up the script's work cause I have too many servers: 500 or so.

Thank you.

Author:  lush [ Mon May 02, 2011 12:09 pm ]
Post subject:  Re: autorun script over ssh

Ok, I decided to use the following code which suits my needs:
Code:
{
sudo ssh -T $host <<-EOF
      wget -c $path/$file
      nohup bash $file
      exit
EOF
} 2>/dev/null

Page 1 of 1 All times are UTC - 6 hours
© 2000, 2002, 2005, 2007 phpBB Group • http://www.phpbb.com