Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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

fnord


Comment on Re: NET:SSH2 exec syntax usage
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" ');

    or

    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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://899696]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2014-11-29 06:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (203 votes), past polls