hi
help please,
i want to call a cgi program from another cgi program.
i don't want a form(calling cgi by onLoad event),
can i directly call a cgi from another cgi.
please reply me soon
thanks in advance.
Hello sonivikas,
jett's suggestion of using a 'require' statement might do what you are looking for. Using a 'require' will, conceptually speaking, fold the code from the 'require'd program into the calling program so they run/act as one larger program.
Some other options.....
To launch any executable from inside a piece of Perl code, there are three options....
[red]system[/red], [red]exec[/red], and [red]backticks[/red].
exec - kills the current process and starts the specified new program
exec(secondProgram.pl);
system - starts the second program and waits for it to finish and then continues to run.
system(seconProgram.pl);
backticks or grave's accents ` - same as the system function.
Each of these functions should be wrapped in a little error checking......
unless (system(secondProg.pl)) { print "some gripe about life"; }
You could also use 'fork', but the exec and system functions take care of some house keeping that 'fork' does not.
'hope this helps.... [sig]<p> <br><a href=mailto: > </a><br><a href= > </a><br> keep the rudder amid ship and beware the odd typo[/sig]
I believe that require, exec, system, & backticks all asssume the other cgi script is local. This may be what sonivikas is asking, however, to jump to a second page or cgi script that is on a different server wouldn't you use something like this?:
The redirect method will only work if you don't need to come back to the original program again, and if the called cgi program doesn't need METHOD=POST format data.
You can also use the LWP module to call a cgi script on another server. You build a form query, call the remote script using LWP, and parse the "html" returned from the remote script to determine the results. There should be an example of how to do that in a thread on this forum (I'm sure I've posted at least one example.) Tracy Dryden
tracy@bydisn.com
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.