RE: Can System() of Perl be bypassed?

From: NESTING, DAVID M (SBCSI) (dn3723@sbc.com)
Date: 01/28/03

  • Next message: Crispin Cowan: "Re: safe strcpy()?"
    From: "NESTING, DAVID M (SBCSI)" <dn3723@sbc.com>
    To: secprog@securityfocus.com
    Date: Tue, 28 Jan 2003 16:35:30 -0600
    
    

    -----Original Message-----
    From: Brian Hatch [mailto:secprog@ifokr.org]
    Sent: Thursday, 23 January, 2003 12:44
    To: Ian Charnas
    Cc: Sandeep Giri; secprog@securityfocus.com
    Subject: Re: Can System() of Perl be bypassed?

    > open2(\*READ, \*WRITE, '/bin/grep', $sanitized_arg,
    > "/usr/dict/words") or die;

    Note also that in 5.8, if all you're interested in is STDOUT, Perl lets you
    do this:

    open(FH, "-|", "/bin/grep", $sanitized_arg, "/usr/dict/words") or die ...;

    This is somewhat equivalent to doing the fork and exec in list form, which
    would not invoke the shell to parse the command string.

    More goodies: http://www.perldoc.com/perl5.8.0/pod/func/open.html

    David



    Relevant Pages

    • Re: Redirect STDOUT and STDERR to file in ksh
      ... I'm running a perl script which just prints output as it goes to ... to be redirected to the file much faster than than stdout - error ... is decides to buffer its output to that file descriptor. ...
      (comp.unix.shell)
    • Re: Way to "retry" the plot command
      ... then writes the data to stdout. ... program set a write lock ... and then using Grant's idea have a perl ... longer for the perl script to get the file. ...
      (comp.graphics.apps.gnuplot)
    • Re: WinNT ActiveState STDERR and STDOUT
      ... the background and capture the output of STDOUT ... and STDERR for later analysis. ... print("Hello World STDOUT from Perl"); ... I tried fudging it to a different log file (before I read this ...
      (comp.lang.perl.misc)
    • Re: Redirecting STDOUT to Scalar behaves not as expected. Why?
      ... >that it writes STDOUT to a file: ... Perl then Run Programm" businesses orthogonal to each other?!? ...
      (comp.lang.perl.misc)
    • Re: Counting (easy!)
      ... In Perl that is usually written as: ... In most consoles/terminals standard output (STDOUT) is line buffered. ... Since you are printing a newline after $count the value of $count should ...
      (perl.beginners)