Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 1997-12-12
11
205 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
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 

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
 
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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will aim to show you how simple is making a small application in WhizBase, how to add, remove and update data in the DB. I will make a small address book application where you can add, browse, update and remove addresses. I wi…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

856 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