in reply to Re: Re: Using awk within system() or open()
in thread Using awk within system() or open()

open(UPTOP, 'cat /proc/uptime | awk "{ print $1 } |"');
Then $1 will be interpolated by shell, won't it? $1 should be AWK variable, neither Perl's one nor shell's one.

--
Tatsuhiko Miyagawa
miyagawa@cpan.org

Replies are listed 'Best First'.
Re: Re: Re: Re: Using awk within system() or open()
by davorg (Chancellor) on Oct 24, 2001 at 13:13 UTC

    D'oh!

    You're right. Try this instead:

    open(UPTOP, q(cat /proc/uptime | awk '{ print $1 } |'));

    Actually, shouldn't it be:

    open(UPTOP, q(cat /proc/uptime | awk '{ print $1 }'|));

    or even (avoiding the "useless use of cat")

    open(UPTOP, q(awk '{ print $1 }' /proc/uptime |));
    --
    <http://www.dave.org.uk>

    "The first rule of Perl club is you don't talk about Perl club."