Solved

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

Posted on 1997-12-12
11
196 Views
Last Modified: 2013-12-25
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
0
Comment
Question by:mmcw
  • 4
  • 3
  • 2
  • +2
11 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 1831626
#!/bin/perl
system("script1.cgi");
system("script2.cgi");

0
 
LVL 5

Expert Comment

by:icd
ID: 1831627
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
 
LVL 84

Expert Comment

by:ozo
ID: 1831628
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
 

Expert Comment

by:aurelio
ID: 1831629
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
 

Author Comment

by:mmcw
ID: 1831630
Hello,

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

greeting Michel
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 84

Expert Comment

by:ozo
ID: 1831631
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
 

Author Comment

by:mmcw
ID: 1831632
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
 
LVL 5

Expert Comment

by:icd
ID: 1831633
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
 
LVL 84

Expert Comment

by:ozo
ID: 1831634
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
 
LVL 5

Expert Comment

by:icd
ID: 1831635
That might do it ozo.
0
 

Accepted Solution

by:
mac119 earned 100 total points
ID: 1831636
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

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
The viewer will learn how to dynamically set the form action using jQuery.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now