I've got a CGI script where I am trying to run a shell command and report the results. For some reason it works as expected from the command line but not via the web server.
#!/usr/bin/perl -w use Data::Dumper; use CGI qw/:standard/; use CGI::Carp 'fatalsToBrowser'; use strict; $ENV{'PATH'} = '/bin:/usr/bin'; delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'}; my $cmd = qq(rsh case3 /home/dncms/bin/testForwardLookup.pl case3 &|); my $result = ""; print header; print "running {$cmd}\n"; open(FOO,$cmd) || die "Failed to run $cmd: $!"; while (<FOO>) { print "feh: "; $result .= "$_\n"; } close(FOO); print ( $result );
Here's the shell response:
dncms@alien 531 > perl foo.pl Content-Type: text/html; charset=ISO-8859-1 running {rsh case3 /home/dncms/bin/testForwardLookup.pl case3 &|} feh: 130.42.0.117
Here's the sum total of the web response:
running {rsh case3 /home/dncms/bin/testForwardLookup.pl case3 &|}
It doesn't seem to matter whether I use setguid or not. Does anyone have an idea of what I'm doing wrong? Thanks!

In reply to shell redirect CGI failure by gryf

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.