Professional Web Applications Themes

array assignement - PERL Beginners

Hi all, I want to assign to an array the output of operating system command: /usr/bin/ssh roomeradad-bck2 sar -u 1 1|awk '/%usr %sys %wio %idle/ { getline ; printf "%s %s %s %s\n", $2, $3, $4, $5 }' How can I do it? I have some problem because there are a lot of special character... Thank You Mauro...

  1. #1

    Default array assignement

    Hi all,
    I want to assign to an array the output of operating system command:
    /usr/bin/ssh roomeradad-bck2 sar -u 1 1|awk '/%usr %sys %wio %idle/
    { getline ; printf "%s %s %s %s\n", $2, $3, $4, $5 }'
    How can I do it? I have some problem because there are a lot of special
    character...

    Thank You


    Mauro

    Mauro Guest

  2. #2

    Default Re: array assignement

    Mauro wrote: 

    Use backticks (or the qx// operator) to capture output in Perl from a
    system command.

    my array = qx($command);
     

    Don't understand.

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Guest

  3. #3

    Default Re: array assignement

    That's ok Gunnar...
    I wanted to say...
    How can I tell to perl: "take all between qx/ and / without try to
    understend what is written" or well "don't try to sobstitue anything between
    qx/ and /"?

    Thank You

    ----- Original Message -----
    From: "Gunnar Hjalmarsson" <cc>
    To: <org>
    Sent: Thursday, October 14, 2004 12:19 PM
    Subject: Re: array assignement

     
    >
    > Use backticks (or the qx// operator) to capture output in Perl from a
    > system command.
    >
    > my array = qx($command);

    >
    > Don't understand.
    >
    > --
    > Gunnar Hjalmarsson
    > Email: http://www.gunnar.cc/cgi-bin/contact.pl
    >
    > --
    > To unsubscribe, e-mail: org
    > For additional commands, e-mail: org
    > <http://learn.perl.org/> <http://learn.perl.org/first-response>
    >
    >
    >[/ref]

    Mauro Guest

  4. #4

    Default Re: array assignement

    Mauro wrote: 

    In that case, you should read the guidance about that in the
    description of the qx// operator in "perldoc perlop".

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Guest

  5. #5

    Default Re: array assignement

    Mauro wrote: 

    There is a better way. See my last message in this thread.

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Guest

  6. #6

    Default Re: array assignement

    Ok guy I solved my problem.
    The correct line was:

    my pippo = qx/ssh roomer\adad-bck2 sar -u 1 1|awk '\/\%usr \%sys
    \%wio \%idle\/ { getline ; printf "\%s \%s \%s \%s\\n", \$2, \$3, \$4,
    \$5 }'/ ;

    I had problem because perl try to undertand what meant " and / and %..."


    Thank you


    Mauro
    ----- Original Message -----
    From: "Mauro" <it>
    To: <org>
    Sent: Thursday, October 14, 2004 1:39 PM
    Subject: Re: array assignement

     
    between 
    > >
    > > Use backticks (or the qx// operator) to capture output in Perl from a
    > > system command.
    > >
    > > my array = qx($command);
    > > 
    > >
    > > Don't understand.
    > >
    > > --
    > > Gunnar Hjalmarsson
    > > Email: http://www.gunnar.cc/cgi-bin/contact.pl
    > >
    > > --
    > > To unsubscribe, e-mail: org
    > > For additional commands, e-mail: org
    > > <http://learn.perl.org/> <http://learn.perl.org/first-response>
    > >
    > >
    > >[/ref]
    >
    >
    > --
    > To unsubscribe, e-mail: org
    > For additional commands, e-mail: org
    > <http://learn.perl.org/> <http://learn.perl.org/first-response>
    >
    >
    >[/ref]

    Mauro Guest

Similar Threads

  1. array data matches but array created in loop doesn't work
    By Reed Law in forum PHP Development
    Replies: 1
    Last Post: August 13th, 04:25 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139