FAQ
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.

Search Discussions

  • Jeff Pang at Aug 27, 2008 at 4:52 am
    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 : TADIPAH@nationwide.com
    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 prenom.nom@laposte.net
    1 Go d'espace de stockage, anti-spam et anti-virus intégrés.
  • Tadipah at Aug 27, 2008 at 5:05 am
    Thanks a ton Jeff. It works.

    Thanks,
    harsha



    Jeff Pang <pangj@laposte.net>





    08/27/2008 12:52 AM
    Please respond to Jeff Pang <pangj@laposte.net>

    From
    Jeff Pang <pangj@laposte.net>
    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 : TADIPAH@nationwide.com
    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 prenom.nom@laposte.net
    1 Go d'espace de stockage, anti-spam et anti-virus intégrés.
  • Irfan J Sayed (isayed) at Aug 27, 2008 at 8:59 am
    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 cgadgil@$_ /home/cgadgil/avm2.1/launchtomcat.sh"; } close FILE;
    if($?){ print "error \n"; exit 1;}
    else { print "success\n";}

    But it says :
    [cgadgil@avm-int-cam2 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: TADIPAH@nationwide.com
    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 <pangj@laposte.net>





    08/27/2008 12:52 AM
    Please respond to Jeff Pang <pangj@laposte.net>

    From
    Jeff Pang <pangj@laposte.net>
    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 : TADIPAH@nationwide.com
    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 prenom.nom@laposte.net
    1 Go d'espace de stockage, anti-spam et anti-virus intégrés.
  • Raymond Wan at Aug 27, 2008 at 9:05 am
    Hi Irfan,

    Assuming we are using the same ssh, isn't the login name for ssh is
    supplied using the "-l" parameter (lowercase L)? Give it a try on the
    command line before putting it in the script so that you can figure out
    what is wrong easier.

    Ray


    Irfan J Sayed (isayed) wrote:
    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 cgadgil@$_ /home/cgadgil/avm2.1/launchtomcat.sh"; } close FILE;
    if($?){ print "error \n"; exit 1;}
    else { print "success\n";}

    But it says :
    [cgadgil@avm-int-cam2 test]$ perl ssh_test1.pl
    the host is: 172.21.58.149
    ssh: cgadgil: Name or service not known
    Error

    Any help
  • Raymond Wan at Aug 27, 2008 at 9:08 am

    Raymond Wan wrote:
    Assuming we are using the same ssh, isn't the login name for ssh is
    supplied using the "-l" parameter (lowercase L)? Give it a try on the
    command line before putting it in the script so that you can figure
    out what is wrong easier.
    Sorry Irfan and thanks Jeff...I was wrong; I use ssh only one way and
    never tried the other ways... Thanks!

    Ray
  • Jeff Pang at Aug 27, 2008 at 9:02 am
    system "ssh cgadgil@$_ /home/cgadgil/avm2.1/launchtomcat.sh";
    you need a "\" before the "@".
    modify it to:

    system "ssh cgadgil\@$_ /home/cgadgil/avm2.1/launchtomcat.sh";

    Créez votre adresse électronique prenom.nom@laposte.net
    1 Go d'espace de stockage, anti-spam et anti-virus intégrés.
  • Irfan J Sayed (isayed) at Aug 27, 2008 at 9:51 am
    Thanks Jeff. It really helped.
    Just one doubt, if we can perform operation with ssh then why we require Net::SSH module??

    Regards
    Irf.


    -----Original Message-----
    From: Jeff Pang
    Sent: Wednesday, August 27, 2008 2:32 PM
    To: Irfan J Sayed (isayed)
    Cc: beginners@perl.org
    Subject: RE: perl script on remote server linux
    system "ssh cgadgil@$_ /home/cgadgil/avm2.1/launchtomcat.sh";
    you need a "\" before the "@".
    modify it to:

    system "ssh cgadgil\@$_ /home/cgadgil/avm2.1/launchtomcat.sh";

    Créez votre adresse électronique prenom.nom@laposte.net
    1 Go d'espace de stockage, anti-spam et anti-virus intégrés.
  • Irfan J Sayed (isayed) at Aug 28, 2008 at 1:29 pm
    Hi All,

    Now what I need to do is, on remote server I need to open a file and parse that file for errors.
    To do this I did in following way (part of perl code).

    sub conn()
    {
    system "ssh cgadgil\@$value \"open FILE, /home/cgadgil/AVMInstall.log\" or die $!;";
    if ($?){ print "connection failed\n";} else{ print "connection successful\n";}
    }

    But I am getting error as follows.
    Couldnt get a file descriptor referring to the console
    connection failed

    Please suggest.

    Regards
    Irfan.



    -----Original Message-----
    From: Jeff Pang
    Sent: Wednesday, August 27, 2008 2:32 PM
    To: Irfan J Sayed (isayed)
    Cc: beginners@perl.org
    Subject: RE: perl script on remote server linux
    system "ssh cgadgil@$_ /home/cgadgil/avm2.1/launchtomcat.sh";
    you need a "\" before the "@".
    modify it to:

    system "ssh cgadgil\@$_ /home/cgadgil/avm2.1/launchtomcat.sh";

    Créez votre adresse électronique prenom.nom@laposte.net
    1 Go d'espace de stockage, anti-spam et anti-virus intégrés.
  • Tadipah at Aug 28, 2008 at 1:56 pm
    Is there a specific text that you want to parse throught the log file?

    Thanks,
    Harsha



    "Irfan J Sayed (isayed)" <isayed@cisco.com>





    08/28/2008 09:29 AM

    From
    "Irfan J Sayed (isayed)" <isayed@cisco.com>
    To
    "Jeff Pang" <pangj@laposte.net>, <beginners@perl.org>
    cc

    Subject
    RE: perl script on remote server linux







    Hi All,

    Now what I need to do is, on remote server I need to open a file and parse
    that file for errors.
    To do this I did in following way (part of perl code).

    sub conn()
    {
    system "ssh cgadgil\@$value \"open FILE, /home/cgadgil/AVMInstall.log\"
    or die $!;";
    if ($?){ print "connection failed\n";} else{ print "connection
    successful\n";}
    }

    But I am getting error as follows.
    Couldnt get a file descriptor referring to the console
    connection failed

    Please suggest.

    Regards
    Irfan.



    -----Original Message-----
    From: Jeff Pang
    Sent: Wednesday, August 27, 2008 2:32 PM
    To: Irfan J Sayed (isayed)
    Cc: beginners@perl.org
    Subject: RE: perl script on remote server linux
    system "ssh cgadgil@$_ /home/cgadgil/avm2.1/launchtomcat.sh";
    you need a "\" before the "@".
    modify it to:

    system "ssh cgadgil\@$_ /home/cgadgil/avm2.1/launchtomcat.sh";

    Créez votre adresse électronique prenom.nom@laposte.net
    1 Go d'espace de stockage, anti-spam et anti-virus intégrés.

    --
    To unsubscribe, e-mail: beginners-unsubscribe@perl.org
    For additional commands, e-mail: beginners-help@perl.org
    http://learn.perl.org/
  • Irfan J Sayed (isayed) at Aug 28, 2008 at 2:29 pm
    Yes. I want to parse string "error" in the log file.

    Please suggest how should I achieve this.

    Regards
    Irfan.


    ________________________________

    From: TADIPAH@nationwide.com
    Sent: Thursday, August 28, 2008 7:29 PM
    To: Irfan J Sayed (isayed)
    Cc: beginners@perl.org; Jeff Pang
    Subject: RE: perl script on remote server linux



    Is there a specific text that you want to parse throught the log file?

    Thanks,
    Harsha



    "Irfan J Sayed (isayed)" <isayed@cisco.com>





    08/28/2008 09:29 AM
    From
    "Irfan J Sayed (isayed)" <isayed@cisco.com>
    To
    "Jeff Pang" <pangj@laposte.net>, <beginners@perl.org>
    cc
    Subject
    RE: perl script on remote server linux







    Hi All,

    Now what I need to do is, on remote server I need to open a file and parse that file for errors.
    To do this I did in following way (part of perl code).

    sub conn()
    {
    system "ssh cgadgil\@$value \"open FILE, /home/cgadgil/AVMInstall.log\" or die $!;";
    if ($?){ print "connection failed\n";} else{ print "connection successful\n";}
    }

    But I am getting error as follows.
    Couldnt get a file descriptor referring to the console
    connection failed

    Please suggest.

    Regards
    Irfan.



    -----Original Message-----
    From: Jeff Pang
    Sent: Wednesday, August 27, 2008 2:32 PM
    To: Irfan J Sayed (isayed)
    Cc: beginners@perl.org
    Subject: RE: perl script on remote server linux
    system "ssh cgadgil@$_ /home/cgadgil/avm2.1/launchtomcat.sh";
    you need a "\" before the "@".
    modify it to:

    system "ssh cgadgil\@$_ /home/cgadgil/avm2.1/launchtomcat.sh";

    Créez votre adresse électronique prenom.nom@laposte.net
    1 Go d'espace de stockage, anti-spam et anti-virus intégrés.

    --
    To unsubscribe, e-mail: beginners-unsubscribe@perl.org
    For additional commands, e-mail: beginners-help@perl.org
    http://learn.perl.org/
  • Tadipah at Aug 28, 2008 at 2:46 pm
    Try this:

    system "ssh -x -t SERVER_NAME \"sudo /home/irfan.sh/test.sh\" >
    /home/irfan/out.txt ";

    On the desination server, create a file test.sh and add:
    #!/bin/bash
    grep "error" file_name;

    The required output will be in /home/irfan/out.txt on server where you run
    the script.

    Thanks,
    Hary




    "Irfan J Sayed (isayed)" <isayed@cisco.com>





    08/28/2008 10:29 AM

    From
    "Irfan J Sayed (isayed)" <isayed@cisco.com>
    To
    <TADIPAH@nationwide.com>, "Jeff Pang" <pangj@laposte.net>,
    <beginners@perl.org>
    cc

    Subject
    RE: perl script on remote server linux






    Yes. I want to parse string "error" in the log file.

    Please suggest how should I achieve this.

    Regards
    Irfan.


    From: TADIPAH@nationwide.com
    Sent: Thursday, August 28, 2008 7:29 PM
    To: Irfan J Sayed (isayed)
    Cc: beginners@perl.org; Jeff Pang
    Subject: RE: perl script on remote server linux


    Is there a specific text that you want to parse throught the log file?

    Thanks,
    Harsha


    "Irfan J Sayed (isayed)" <isayed@cisco.com>





    08/28/2008 09:29 AM

    From
    "Irfan J Sayed (isayed)" <isayed@cisco.com>
    To
    "Jeff Pang" <pangj@laposte.net>, <beginners@perl.org>
    cc

    Subject
    RE: perl script on remote server linux









    Hi All,

    Now what I need to do is, on remote server I need to open a file and parse
    that file for errors.
    To do this I did in following way (part of perl code).

    sub conn()
    {
    system "ssh cgadgil\@$value \"open FILE, /home/cgadgil/AVMInstall.log\" or
    die $!;";
    if ($?){ print "connection failed\n";} else{ print "connection
    successful\n";}
    }

    But I am getting error as follows.
    Couldnt get a file descriptor referring to the console
    connection failed

    Please suggest.

    Regards
    Irfan.



    -----Original Message-----
    From: Jeff Pang
    Sent: Wednesday, August 27, 2008 2:32 PM
    To: Irfan J Sayed (isayed)
    Cc: beginners@perl.org
    Subject: RE: perl script on remote server linux
    system "ssh cgadgil@$_ /home/cgadgil/avm2.1/launchtomcat.sh";
    you need a "\" before the "@".
    modify it to:

    system "ssh cgadgil\@$_ /home/cgadgil/avm2.1/launchtomcat.sh";

    Créez votre adresse électronique prenom.nom@laposte.net
    1 Go d'espace de stockage, anti-spam et anti-virus intégrés.

    --
    To unsubscribe, e-mail: beginners-unsubscribe@perl.org
    For additional commands, e-mail: beginners-help@perl.org
    http://learn.perl.org/
  • Irfan J Sayed (isayed) at Aug 29, 2008 at 7:39 am
    Thanks. It worked but with one issue.

    Let say if "error" keyword is not there in the log file then the file which is being created as a part of the redirection (output file) is empty.
    so Perl interpreter says that " connection failed"

    and if suppose "error " string the log file then in the output file "error" word will come and then it says connection successful.

    but my query is that in both the cases (irrespective whether error word is there are not in the log file) Perl should print connection successful.

    Please suggest

    Regards
    Irf

    ________________________________

    From: TADIPAH@nationwide.com
    Sent: Thursday, August 28, 2008 8:18 PM
    To: Irfan J Sayed (isayed)
    Cc: beginners@perl.org; Jeff Pang
    Subject: RE: perl script on remote server linux



    Try this:

    system "ssh -x -t SERVER_NAME \"sudo /home/irfan.sh/test.sh\" > /home/irfan/out.txt ";

    On the desination server, create a file test.sh and add:
    #!/bin/bash
    grep "error" file_name;

    The required output will be in /home/irfan/out.txt on server where you run the script.

    Thanks,
    Hary




    "Irfan J Sayed (isayed)" <isayed@cisco.com>





    08/28/2008 10:29 AM
    From
    "Irfan J Sayed (isayed)" <isayed@cisco.com>
    To
    <TADIPAH@nationwide.com>, "Jeff Pang" <pangj@laposte.net>, <beginners@perl.org>
    cc
    Subject
    RE: perl script on remote server linux






    Yes. I want to parse string "error" in the log file.

    Please suggest how should I achieve this.

    Regards
    Irfan.



    ________________________________

    From: TADIPAH@nationwide.com
    Sent: Thursday, August 28, 2008 7:29 PM
    To: Irfan J Sayed (isayed)
    Cc: beginners@perl.org; Jeff Pang
    Subject: RE: perl script on remote server linux


    Is there a specific text that you want to parse throught the log file?

    Thanks,
    Harsha


    "Irfan J Sayed (isayed)" <isayed@cisco.com>





    08/28/2008 09:29 AM
    From
    "Irfan J Sayed (isayed)" <isayed@cisco.com>
    To
    "Jeff Pang" <pangj@laposte.net>, <beginners@perl.org>
    cc
    Subject
    RE: perl script on remote server linux









    Hi All,

    Now what I need to do is, on remote server I need to open a file and parse that file for errors.
    To do this I did in following way (part of perl code).

    sub conn()
    {
    system "ssh cgadgil\@$value \"open FILE, /home/cgadgil/AVMInstall.log\" or die $!;";
    if ($?){ print "connection failed\n";} else{ print "connection successful\n";}
    }

    But I am getting error as follows.
    Couldnt get a file descriptor referring to the console
    connection failed

    Please suggest.

    Regards
    Irfan.



    -----Original Message-----
    From: Jeff Pang
    Sent: Wednesday, August 27, 2008 2:32 PM
    To: Irfan J Sayed (isayed)
    Cc: beginners@perl.org
    Subject: RE: perl script on remote server linux
    system "ssh cgadgil@$_ /home/cgadgil/avm2.1/launchtomcat.sh";
    you need a "\" before the "@".
    modify it to:

    system "ssh cgadgil\@$_ /home/cgadgil/avm2.1/launchtomcat.sh";

    Créez votre adresse électronique prenom.nom@laposte.net
    1 Go d'espace de stockage, anti-spam et anti-virus intégrés.

    --
    To unsubscribe, e-mail: beginners-unsubscribe@perl.org
    For additional commands, e-mail: beginners-help@perl.org
    http://learn.perl.org/
  • Irfan J Sayed (isayed) at Sep 1, 2008 at 7:29 am
    Hi,

    Please suggest.

    Regards,
    Irfan.


    ________________________________

    From: Irfan J Sayed (isayed)
    Sent: Friday, August 29, 2008 1:09 PM
    To: 'TADIPAH@nationwide.com'; Jeff Pang; beginners@perl.org
    Subject: RE: perl script on remote server linux


    Thanks. It worked but with one issue.

    Let say if "error" keyword is not there in the log file then the file which is being created as a part of the redirection (output file) is empty.
    so Perl interpreter says that " connection failed"

    and if suppose "error " string the log file then in the output file "error" word will come and then it says connection successful.

    but my query is that in both the cases (irrespective whether error word is there are not in the log file) Perl should print connection successful.

    Please suggest

    Regards
    Irf

    ________________________________

    From: TADIPAH@nationwide.com
    Sent: Thursday, August 28, 2008 8:18 PM
    To: Irfan J Sayed (isayed)
    Cc: beginners@perl.org; Jeff Pang
    Subject: RE: perl script on remote server linux



    Try this:

    system "ssh -x -t SERVER_NAME \"sudo /home/irfan.sh/test.sh\" > /home/irfan/out.txt ";

    On the desination server, create a file test.sh and add:
    #!/bin/bash
    grep "error" file_name;

    The required output will be in /home/irfan/out.txt on server where you run the script.

    Thanks,
    Hary




    "Irfan J Sayed (isayed)" <isayed@cisco.com>





    08/28/2008 10:29 AM
    From
    "Irfan J Sayed (isayed)" <isayed@cisco.com>
    To
    <TADIPAH@nationwide.com>, "Jeff Pang" <pangj@laposte.net>, <beginners@perl.org>
    cc
    Subject
    RE: perl script on remote server linux






    Yes. I want to parse string "error" in the log file.

    Please suggest how should I achieve this.

    Regards
    Irfan.



    ________________________________

    From: TADIPAH@nationwide.com
    Sent: Thursday, August 28, 2008 7:29 PM
    To: Irfan J Sayed (isayed)
    Cc: beginners@perl.org; Jeff Pang
    Subject: RE: perl script on remote server linux


    Is there a specific text that you want to parse throught the log file?

    Thanks,
    Harsha


    "Irfan J Sayed (isayed)" <isayed@cisco.com>





    08/28/2008 09:29 AM
    From
    "Irfan J Sayed (isayed)" <isayed@cisco.com>
    To
    "Jeff Pang" <pangj@laposte.net>, <beginners@perl.org>
    cc
    Subject
    RE: perl script on remote server linux









    Hi All,

    Now what I need to do is, on remote server I need to open a file and parse that file for errors.
    To do this I did in following way (part of perl code).

    sub conn()
    {
    system "ssh cgadgil\@$value \"open FILE, /home/cgadgil/AVMInstall.log\" or die $!;";
    if ($?){ print "connection failed\n";} else{ print "connection successful\n";}
    }

    But I am getting error as follows.
    Couldnt get a file descriptor referring to the console
    connection failed

    Please suggest.

    Regards
    Irfan.



    -----Original Message-----
    From: Jeff Pang
    Sent: Wednesday, August 27, 2008 2:32 PM
    To: Irfan J Sayed (isayed)
    Cc: beginners@perl.org
    Subject: RE: perl script on remote server linux
    system "ssh cgadgil@$_ /home/cgadgil/avm2.1/launchtomcat.sh";
    you need a "\" before the "@".
    modify it to:

    system "ssh cgadgil\@$_ /home/cgadgil/avm2.1/launchtomcat.sh";

    Créez votre adresse électronique prenom.nom@laposte.net
    1 Go d'espace de stockage, anti-spam et anti-virus intégrés.

    --
    To unsubscribe, e-mail: beginners-unsubscribe@perl.org
    For additional commands, e-mail: beginners-help@perl.org
    http://learn.perl.org/
  • Jeff Pang at Aug 27, 2008 at 10:14 am

    Message du 27/08/08 11:51
    De : "Irfan J Sayed (isayed)"
    A : "Jeff Pang"
    Copie à : beginners@perl.org
    Objet : RE: perl script on remote server linux



    Thanks Jeff. It really helped.
    Just one doubt, if we can perform operation with ssh then why we require Net::SSH module??

    Net::SSH is a Perl module, but system "ssh ..." is going with external system call, which is not as recommanded as Net::SSH I think.


    Regards,
    Jeff.

    Créez votre adresse électronique prenom.nom@laposte.net
    1 Go d'espace de stockage, anti-spam et anti-virus intégrés.
  • Jeff Pang at Aug 28, 2008 at 1:41 pm
    Hi,
    system "ssh cgadgil\@$value \"open FILE, /home/cgadgil/AVMInstall.log\"
    This will not open a file on remote host.
    Since you call the external ssh command, all arguments given to this command will be in shell statement, not in Perl syntax.

    "open FILE, /home/cgadgil/AVMInstall.log" is a Perl open, shell can't understand for this at all.



    Message du 28/08/08 15:29
    De : "Irfan J Sayed (isayed)"
    A : "Jeff Pang" , beginners@perl.org
    Copie à :
    Objet : RE: perl script on remote server linux



    Hi All,

    Now what I need to do is, on remote server I need to open a file and parse that file for errors.
    To do this I did in following way (part of perl code).

    sub conn()
    {
    system "ssh cgadgil\@$value \"open FILE, /home/cgadgil/AVMInstall.log\" or die $!;";
    if ($?){ print "connection failed\n";} else{ print "connection successful\n";}
    }

    But I am getting error as follows.
    Couldnt get a file descriptor referring to the console
    connection failed

    Please suggest.

    Regards
    Irfan.



    -----Original Message-----
    From: Jeff Pang
    Sent: Wednesday, August 27, 2008 2:32 PM
    To: Irfan J Sayed (isayed)
    Cc: beginners@perl.org
    Subject: RE: perl script on remote server linux
    system "ssh cgadgil@$_ /home/cgadgil/avm2.1/launchtomcat.sh";
    you need a "\" before the "@".
    modify it to:

    system "ssh cgadgil\@$_ /home/cgadgil/avm2.1/launchtomcat.sh";

    Créez votre adresse électronique prenom.nom@laposte.net
    1 Go d'espace de stockage, anti-spam et anti-virus intégrés.

    Regards,
    Jeff.

    Créez votre adresse électronique prenom.nom@laposte.net
    1 Go d'espace de stockage, anti-spam et anti-virus intégrés.
  • Jeff Pang at Aug 28, 2008 at 2:37 pm
    Try something like:

    system "ssh user\@host \"grep 'error info' sth.log\" ";

    you could use shell's grep or sed to view/edit the remote file.


    Message du 28/08/08 16:29
    De : "Irfan J Sayed (isayed)"
    A : TADIPAH@nationwide.com, "Jeff Pang" , beginners@perl.org
    Copie à :
    Objet : RE: perl script on remote server linux

    Yes. I want to parse string "error" in the log file.

    Please suggest how should I achieve this.


    Regards,
    Jeff.

    Créez votre adresse électronique prenom.nom@laposte.net
    1 Go d'espace de stockage, anti-spam et anti-virus intégrés.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupbeginners @
categoriesperl
postedAug 27, '08 at 4:33a
activeSep 1, '08 at 7:29a
posts17
users4
websiteperl.org

People

Translate

site design / logo © 2022 Grokbase