Hi, In my case, the user with which I am executing the script is not there in sudoers file. So I did in the following manner. #!/usr/bin/perl
open FILE, "server_list" or die $!; while(<FILE>) { print "the host is: $_"; chomp; system "ssh [EMAIL PROTECTED] /home/cgadgil/avm2.1/launchtomcat.sh"; } close FILE; if($?){ print "error \n"; exit 1;} else { print "success\n";} But it says : [EMAIL PROTECTED] test]$ perl ssh_test1.pl the host is: 172.21.58.149 ssh: cgadgil: Name or service not known Error Any help Regards Irf -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 27, 2008 10:38 AM To: Jeff Pang Cc: Perl Beginners [Beginners Perl] Subject: Re:perl script on remote server linux Thanks a ton Jeff. It works. Thanks, harsha Jeff Pang <[EMAIL PROTECTED]> 08/27/2008 12:52 AM Please respond to Jeff Pang <[EMAIL PROTECTED]> From Jeff Pang <[EMAIL PROTECTED]> To "Perl Beginners [Beginners Perl]" <beginners@perl.org> cc Subject Re:perl script on remote server linux Try the code below, wish it works fine for you. open FILE, "server_list.txt" or die $!; while(<FILE>) { print "the host is: $_"; chomp; system "ssh -x -t $_ \"sudo /home/tadipah/test.sh\" "; } close FILE; --Jeff > Message du 27/08/08 06:33 > De : [EMAIL PROTECTED] > A : beginners@perl.org > Copie à : > Objet : perl script on remote server linux > > 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 = ; > $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. Créez votre adresse électronique [EMAIL PROTECTED] 1 Go d'espace de stockage, anti-spam et anti-virus intégrés. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/