http://www.perlmonks.org?node_id=899696


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

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" ');

    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\" ");