Thank you Bob,
    This works for me.  One further question.  I thought I read somewhere
that you should
not put full paths in a CGI program for security reasons.  Should that be a
consideration?
Maureen


Bob Showalter wrote:

> > -----Original Message-----
> > From: Maureen E Fischer [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, July 17, 2002 2:37 PM
> > To: [EMAIL PROTECTED]
> > Subject: exec statement
> >
> >
> > Hello,
> > I am trying to go to a script from within a script.  This is
> > a Perl CGI
> > script and I want to transfer to various other perl cgi
> > scripts based on
> > user selections.  From what I read I want to use exec for
> > this -- since
> > I want to leave and not return to the transferring script.  The
> > trasferring program outputs a screen heading (as it should) and just
> > sits there --I get no error message --  it doesn't matter what name I
> > put in as the program that I am transferring to (even if I put in a
> > garbage name) nothing seems to happen.  I would have expected
> > it to die
> > and give me a message based on the garbage name. This is the code:
> >
> >  # # # # # # # # # # # # # # # # # # # #
> > # PRINT HEADING
> > # # # # # # # # # # # # # # # # # # # # # #
> >     print "Content-type: text/html\n\n";
> >         print <<Heading;
> >             <HTML><HEAD><TITLE>CAE Solutions</TITLE></HEAD>
> >             <BODY BGCOLOR="teal" TEXT="silver">
> >             <h1 align="center">CAE Solutions</h1>
> >             <BR>
> >             <BR>
> > Heading
> >
> > # # # # # # # # # # # # # # # # # # # # # #
> > # MAIN LOGIC
> > # # # # # # # # # # # # # # # # # # # # # #
> >
> >     if ($work_type eq 'en') {
> >         print "I'm ready to leave\n\n";
> > #   exec("log_enh.cgi $validemp")
> >         exec("tslslslsestit.cgi $validemp")
> >          or die "Couldni\'t go to log_enhi.cgi: $!\n";
> >         print "I'm BACK!!!! \n\n";
> >         };
> >
> > Thanks,
> > Maureen
>
> The exec will search your PATH to find the script, so you need
> something like:
>
>    exec './myscript.pl', $validemp;
>    die "Couldn't exec: $!";
>
> In my testing, the die() would write to the error log properly.
>
> (Probably, you should specify the full path to the script and not
> make any assumptions about the current working directory when
> running under a CGI environment).
>
> Splitting the elements into a list here ensures that execvp(3) is
> called instead of /bin/sh.
>
> perldoc -f exec
> man 3 execvp



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to