in reply to Differences between CGI and command-line versions of scripts?!?

What's the error in the error logs? Maybe you need to specify the full path to the command (in CGI the PATH is probably not the same). Since you are opening a pipe you should also check the status of the close() command (And as others have suggested, include '$!' in the error message).

Also I don't get why you are checking for a newline at the end of every line read in. There should be a newline at the end of every line read in (except maybe the last one, is that what that's for?).

  • Comment on Re: Differences between CGI and command-line versions of scripts?!?

Replies are listed 'Best First'.
Re: Re: Differences between CGI and command-line versions of scripts?!?
by dws (Chancellor) on Apr 04, 2001 at 00:12 UTC
    (in CGI the PATH is probably not the same)

    Exactly. Unless "." is in $ENV{PATH}, (which is probably won't be when the CGI is invoked), your open() will fail. Replace   open(PS, "ejbreg.pl |") || die "Can't open script"; with   open(PS, "./ejbreg.pl |" ) or die "Can't open script: $!"; And depending on the webserver, you may need to chdir() to get where you need to be.

      Sorry, this seems to have caused some confusion. My actual script looks like:

      my $process='perl c:\winnt\profiles\jbw\builder\' . "guibuilder.pm $NAME $PASS $BOPT $IWEB $INAS $IAPP " . "$IHLP $VERB |"; open(PH, "$process") || die "Can't open process: $process -- $! ";

      Again, the script runs fine from both command line and cgi. It just can't seem to access the LDAP server from cgi...and I can't seem to figure out why.

      Thanks for the tip anyway!