Starting two script from one form using once the submit button.

Hello,

Is there a way to start out of a form two script using once the submit button. I have two scripts. I wan't to use them seperetly, but there is a place where I wan't two use them together at the same time with the same form input!

Is this possible

greeting Michel Weegerink
mmcwAsked:
Who is Participating?
 
mac119Connect With a Mentor Commented:
The previous comments suggest a method which should work (a bit messily), but why wouldn't you simply have the first script output a redirect to the second, so that the browser would repost the data to the second script?
0
 
ozoCommented:
#!/bin/perl
system("script1.cgi");
system("script2.cgi");

0
 
icdCommented:
It's not so simple as ozo suggests. Assuming the form uses a POST method the first script run will empty the stdin stream leaving no data for the second script. Also if both scripts write to stdout then there will be a problem.

I do call two scripts on one of my web sites with the condition that script1 does not read from stdin and does not write to stdout. (It only provides a log function). I don't think this will work in your case however since both scripts need access to the form input.

I am currently investigating the possibility of calling a script on another server from my own script. The outline of the method is as follows:-

form1.html calls script1.pl running on my server.
script1.pl parses the output of form1.html and opens a socket to the script2.pl URL on the other server, passing the data received from form1.html through to script2.pl

A more practical solution for you might be to create four files.

script1.pl
script2.pl
script3.pl
library.pm

script1.pl script2.pl and script3.pl are three simple scripts, each of which requires library.pm and call routines stored in library.pm

the files would look something like:-

--- script1.pl ---
#!/usr/local/bin/perl
require Library.pm
&Library::function1;

--- script2.pl ---
#!/usr/local/bin/perl
require Library.pm
&Library::function2;

--- script3.pl ---
#!/usr/local/bin/perl
require Library.pm
&Library::function1;
&Library::function2;

---

If you organise your functions correctly then I am sure you will be able to do what you want.


0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
ozoCommented:
Well, it depends what the scripts do, and what you want to do when you use both.
I can think of cgi programs that can be combined that simply,
but I agree that reorganizing the functions would usually be a better aproach.
0
 
aurelioCommented:
Also can try a dirtier approach : if the first script has read stdin , and has exhausted it , look for a premature EOF before CONTENT_LENGTH in the second one ; suppose in this case that all the form input has been eat by the first script.an proceed accordingly.
0
 
mmcwAuthor Commented:
Hello,

Is the library.pm file part of perl5 or where do I get this file?

greeting Michel
0
 
ozoCommented:
I think what icd was suggesting was that you could create a new file caled library.pm
into which you could put the functions you wish to use in common between your 3 scripts.

0
 
mmcwAuthor Commented:
Hello,

I don't understand the answers.
Maybe I did not tell the question good.
The question is a follow:
I have two perl scripts. One called: wedl.pl. The other called: form_proccessor.pl. Both they need the input out of the same html form. They both need the same email address input. I wan't to use one html form with one submit button. I wan't to push the one button and so make the two perl script go to work. Is this possible without rewriting the scripts. I don't know how to rewrite them and I need the perl script sepretely also.

greeting michel
0
 
icdCommented:
Have you thought where the output of the two scripts should go? They both can't go to the same browser window.

Perhaps possible with cunning Javascript, two frames, one holding the input form. On submitting the form you write an 'onSubmit' handler which creates a form in the second frame, fills it in with data from the first form and submit it to wedl.pl then submits itself to form_processor.pl. Each script then outputs to a separate frame.

Very messy, not elegant, more trouble than 100 points (or in fact 200 or so in my opinion). Far simpler to re-write your scripts.

0
 
ozoCommented:
If your two scripts can take GET input, perhaps you could do something like:

#!/usr/local/bin/perl
$query = $ENV{QUERY_STRING} || <>;
print <<HERE;
Content-Type: text/html


<HTML>
<HEAD><title>two scripts</title></head>
<FRAMESET rows=300,300>
<FRAME SRC="wedl.pl?$query">
<FRAME SRC="form_proccessor.pl?$query">
</FRAMESET>
</HTML>
HERE

0
 
icdCommented:
That might do it ozo.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.