CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
remote script execution on linux

 



tadi18
Novice

Aug 26, 2008, 9:16 PM

Post #1 of 2 (327 views)
remote script execution on linux Can't Post

I am trying to execute a perl script from source A to invoke another script on 5 remote servers. The script is as follows:

#!/usr/bin/perl

open file, "server_list.txt";
@content = <file>;
$tot=$#content+1;
print "$tot \n";

while ($tot > 0)
{
$m = shift @content;
print "$m \n";
`ssh -x -t $m "sudo /home/tadipah/test.sh"` ;
sleep 5;
exit
}
Server_list above has the list of servers the script needs to be executed on.
Above script works fine until it connects to the server and asks me the password. After I type the password, the putty sessions freezes.

When I use the line below alone without the while or foreach loop, it works absolutely fine and returns me the output of the script test.sh from remote computer.
`ssh -x -t SERVERNAME "sudo /home/tadipah/test.sh"` ;

Any help is appreciated.


jcaleffi
New User

Aug 27, 2008, 4:16 AM

Post #2 of 2 (319 views)
Re: [tadi18] remote script execution on linux [In reply to] Can't Post

Trying using system() instead of `` to call ssh. Your while loop is not right as you are not incrementing $tot, try it:

Code
#!/usr/bin/perl 

open file, "server_list.txt";
@content = <file>;

while (@content)
{
$m = shift @content;
print "$m \n";
system("ssh -x -t $m 'sudo /home/tadipah/test.sh'");
sleep 5;
}
exit


Regards


(This post was edited by jcaleffi on Aug 27, 2008, 4:16 AM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives