Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Using shell pipes with perl

Expand Messages
  • Jabir Ahmed
    try using the open command eg open(HANDLE, ls -al|grep | ); i had the same issue sometime back and solved it not sure if this was the solution but if it works
    Message 1 of 3 , Jun 26 9:42 AM
    • 0 Attachment
      try using the open command
      eg
      open(HANDLE," ls -al|grep |");

      i had the same issue sometime back and solved it
      not sure if this was the solution but if it works then gr8 otherwise wil update with the solution.

      rgds
      ----- Original Message -----
      From: frederico.caldeira@...
      To: perl-beginner@yahoogroups.com
      Sent: Tuesday, June 26, 2007 9:22 PM
      Subject: [PBML] Using shell pipes with perl


      Hi everybody,

      I am trying to convert some bash scripts to perl. Could somebody
      give me a hint how to get the result of the bash sequence below?

      vxdmpadm listctlr all | grep GENESIS | awk '/ENABLE/ {print $1}' |
      sort -t c -k 2,3n | tr "\n" " "

      This command give me the following result:

      root@sol01># vxdmpadm listctlr all | grep GENESIS | awk '/ENABLE/
      {print $1}' | sort -t c -k 2,3n | tr "\n" " "
      c4 c5

      The vxdmpadm command result:

      root@sol01># vxdmpadm listctlr all
      CTLR-NAME ENCLR-TYPE STATE ENCLR-NAME
      =====================================================
      c0 Disk ENABLED Disk
      c3 EMC_CLARiiON ENABLED EMC_CLARiiON0
      c2 EMC_CLARiiON ENABLED EMC_CLARiiON0
      c5 GENESIS ENABLED GENESIS0
      c4 GENESIS ENABLED GENESIS0

      I tried using chop, but the "awk" part appears not working:

      chop (my $status = `(((vxdmpadm listctlr all) | grep GENESIS) | awk
      '{print $1}')`);
      print "\n\nmake exit status:\n$status\n";

      Results:

      make exit status:
      c5 GENESIS ENABLED GENESIS0
      c4 GENESIS ENABLED GENESIS0

      TIA,

      Fred

      [Non-text portions of this message have been removed]





      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.