saravanansh-

No problem! I do this all of the time with Net::SSH::Perl. You must make sure you have your quotes and escapes correct (which usually takes a bit of fiddling), but I usually build the scripts up command-by-command while testing them out. Also remember that you usually get /bin/sh as your shell unless you specify otherwise.

I usually end up with things as shown below. This particular ksh shell script will log the event in a logfile, then pre-process what I send on STDIN via Net::SSH::Perl, and provide it to a local command on the destination machine. The results ends up in $stdout.

my $cmd = '/usr/bin/ksh -c \' LOGDIR=/log/predecode LOGFILE=$LOGDIR/usage`date \'+%m\'` if [ -w $LOGFILE ] ; then echo "$LOGNAME; `date \"+%D %T\"`;`uname -a`;${DISPLAY:-SS +H:$SSH_CONNECTION}" >>$LOGFILE fi while read LINE do if [ "$LINE" == "" ] then continue; fi PRE="${LINE%%\|*}" POST="${LINE#[0-9]*\|}" if [ "${POST%%[A-Z]*}" == "_" ] then print "$PRE|$POST" continue; fi ( print -n "$PRE|"; echo $POST | ' . /usr/bin/farendcommand . ' print "\n" ) done\''; my ($stdout, $stderr, $exit) = $ssh->cmd($cmd, $inputForFarEnd);

In reply to Re: Passing the shell script in ssh->cmd option by cmv
in thread Passing the shell script in ssh->cmd option by saravanansh

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.