Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: NET:SSH2 exec syntax usage

by Illuminatus (Curate)
on Apr 15, 2011 at 22:20 UTC ( #899696=note: print w/replies, xml ) Need Help??

in reply to NET:SSH2 exec syntax usage

  1. Your zcat command is encased in single-quotes, which means that variable substitution will not occur.
  2. It is not totally clear from the documentation, but I am pretty sure that setting blocking to 0 means non-blocking. Since the ls probably returns right away, this makes no difference in the first case. zcat, however, can take a while on files of non-trivial size. Since you are not checking for EAGAIN, this could give you a problem


Replies are listed 'Best First'.
Re^2: NET:SSH2 exec syntax usage
by SitrucHtims (Novice) on Apr 15, 2011 at 23:46 UTC

    Illuminatus is correct. If you want to use single quotes, you will have to concatenate your variables. Otherwise you can switch them to double quotes and backslash your literal double-quotes.

    ex. $chan->exec('zcat /db2home/idsldap/idsslapd-idsldap/logs/ibmslapd.log.' . $ibmslapd_fn . '-2350.gz | grep -i "entries have been successfully" ');


    ex. $chan->exec("zcat /db2home/idsldap/idsslapd-idsldap/logs/ibmslapd.log.$ibmslapd_fn-2350.gz | grep -i \"entries have been successfully\" ");

      Thank You SitrucHtims.

      This Worked
      ex. $chan->exec('zcat /db2home/idsldap/idsslapd-idsldap/logs/ibmslapd.log.' . $ibmslapd_fn . '-2350.gz | grep -i "entries have been successfully" ');

      This Didn't
      escaping the double quotes didn't work...
      $chan->exec("zcat /db2home/idsldap/idsslapd-idsldap/logs/ibmslapd.log.$ibmslapd_fn-2350.gz | grep -i \"entries have been successfully\" ");

      Thanks again for your assistance. My Issue is solved.

      The $chan->blocking(0); statement didn't seem to matter.

        The double quotes failed because I missed escaping the "|" character. It is another perl special character. Should work fine as below.

        $chan->exec("zcat /db2home/idsldap/idsslapd-idsldap/logs/ibmslapd.log.$ibmslapd_fn-2350.gz \| grep -i \"entries have been successfully\" ");

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://899696]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2018-06-21 09:09 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (117 votes). Check out past polls.