Re: need your helpppp



Debbie523 wrote:

I have a perl script named try.cgi, which is the action value of a form
containned in
test12.php file.Part of my try.cgi is as following:

#!/bin/perl -w
use strict;
use CGI;

use CGI::Carp qw{fatalsToBrowser};
my

$query=new CGI;

my $nominees=$query->param('n1');
my $nominations=$query->param('n2');
my $leaders=$query->param('n3');
my $followers=$query->param('n4');
my $filename=$query->param('f1');

print $query->header();


exec ("pl.cgi") or die "Failed to exec pl.cgi: $!";


print <<END_HTML;

<html>
.
.
.
</html>
END_HTML



p1.cgi is a executable I get from after executing command:

gcc -o p1.cgi p1.c

in unix shell.

And the function of p1.cgi is writing word "welcome" to file op.txt

Also it works fine if I use command "p1.cgi" in unix shell.

but if I executed from test12.php, after I submit the form there, it
goes

to page try.cgi and display the value $nominees, $nominations ......(I
just let

them get printed in <html> section of try.cgi. But it looks like does
not

execute the command exec ("p1.cgi").Coze I can't see word in op.txt
file.

I spent a lot time on this question. Could someone help me?

Thanks a lot!


I'm no expert, but ...

It seems to me that the first thing is to figure out why the exec fails. If you read the documentation (hint: perldoc -f exec) you'll see something like the code I have inserted. There are differences between executing a Perl script from the command line and executing it as a CGI script, which include the setting of the PATH variable, and the accessability of files in general. Dumping the status of the exec call will help you diagnose this.

But I predict that you will find a second problem when you get the first one sorted out, because I predict that when you run try.cgi from the shell, you will not get the HTML output, except for the headers, if the exec succeeds. See the documentation on exec for the answer to this one, too.

Tom Wyant
.



Relevant Pages

  • Re: exec "echo $PATH"
    ... I have a problem with executing commands with "$" or other spacial ... exec command does not use a shell, ... The first word in each command is taken as the ... exec echo ...
    (comp.lang.tcl)
  • Re: First-time forking
    ... Calling exec() within a pseudo-process actually spawns the requested ... running the bedrock command. ... Actually, most of the time when you're executing system commands, ...
    (perl.beginners)
  • Re: system or exec
    ... overall in the ammount of time it takes for external ... > command to be executed, ... exec is faster. ... A *lot* faster when the time spent executing the rest ...
    (comp.lang.perl.misc)
  • Execution of multiple processes/commands
    ... I have this problem with "exec" in TCL, ... It seems to me that the "cd" works, but the make command isn't: ... while executing ... Either doesn't the current context get switched to the "cd $dir2" part ...
    (comp.lang.tcl)
  • Re: [Full-Disclosure] Fix for IE ADODB.Stream vulnerability is out
    ... There is nothing wrong with the functionality ... create a self-executing html, cross over to the Local Zone and ... executing html demo. ...
    (NT-Bugtraq)