Dear monks,

I am writing a script to check the installed perl modules and its versions in different remote systems. I am using 'Net::SSH::Expect' module for executing the command in remote systems. The following is the sample code.
#!/usr/bin/perl use Net::SSH::Expect; my $host = "testserver"; my $user = "test"; my $password = "pass"; my $ssh = Net::SSH::Expect->new ( host => $host, password=> $password, user => $user, raw_pty => 1, timeout => 10 ); my $login_output = $ssh->login(); my $cmd = qq(perl -e 'use ExtUtils::Installed; my ($inst) = ExtUtils:: +Installed->new(); my (@modules) = $inst->modules(); map { print $_ . +":" . $inst->version($_) ."\n"; }@modules;'); my $res = $ssh->exec($cmd); print($res); $ssh->close();
While executing the command, i'm getting the following error
>new(); my () = ->modules(); map { print . ":" . ->version() ." > "; };' Can't declare stub in "my" at -e line 1, near ") =" syntax error at -e line 1, near "= ->modules" syntax error at -e line 1, near ". ->version" syntax error at -e line 2, near "};" (Might be a runaway multi-line "" string starting on line 1) Execution of -e aborted due to compilation errors.
If I execute the command manually in remote server using SSH client, i'm getting the output.

Can someone throw some light on this.

-lamp

In reply to Error while executing a command using Net::SSH::Expect by lamp

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.