Solved

linking two cgi scripts

Posted on 1997-07-02
9
184 Views
Last Modified: 2013-12-25
i have a form on my web page that i use for people to send pages to my alphanumeric pager.  First, they fill out a form and hit a button, and that perl script mails me the content of their page, and then builds another page with another button on it that they have to hit to run another cgi
script on another pc that i don't have access to...

what i'd like to do is combine these steps..is there a way for me to run the first script,and then hand off the processing to the 2nd script on another computer?  or maybe make the first script open up lynx on my account and enter the data on the 2nd site, returning data whether it
worked or not?

you can see what i'm talking about by going to my web page @ http://www.tensionboy.com/contact.html

0
Comment
Question by:tonysebion
  • 5
  • 3
9 Comments
 
LVL 5

Expert Comment

by:icd
ID: 1828685
As far as I can tell, you have two scripts. The first is one you wrote that logs for your purposes who made the 'call' and the second is one provided by (presumably) the pager company.

My first impression was that you should just include the hidden fields on the second page as hidden fields in the first page, but then I realised you were probably doing further logging.

The next option is to use Javascript or a META command so that when your first script is run it does a refresh to automatically run the second script after a short pause.

The best approach however might be to re-write the second script so that it produces no output (unless there is an error detected), it just carries out the logging function. It would then need to request the document produced by the second script using http and output the result to stdout. In that way although both scripts are run, only the output of the second script is shown.

How to do this will vary depending upon the server software. I have a solution if the server is running on Win95 or NT. If it is UNIX then my code would not work but a similar approach could be worked out.
0
 
LVL 5

Expert Comment

by:icd
ID: 1828686
Sorry, that should read 'The best approach might be to re-write the *first* script'
0
 

Author Comment

by:tonysebion
ID: 1828687
okey, if you go to the page and follow it, the first form you fill out (and hit send on) runs a little perl thing that mails me the contents of the page, and builds a 2nd web page with the 2nd form on it (hidden fields contain the data for the 2nd cgi script to follow).

what i want is BOTH cgi's to process (the first one, that i can edit - which mails me the contents of the page, and the 2nd one, which i CAN'T - that actually does the page itself)

i'm against using a scripting language solution, as that's not compatable on all browsers or is turned off for security reasons often...i'd like to do it on my end, and i think the best solution would be to start up lynx on my shell acct and process the second script from within the 1st one, and then dealing w/ the data.....


0
 
LVL 7

Expert Comment

by:faster
ID: 1828688
If you have enough time, you can modify your 1st script such that it does not generate another html page for the 2nd script, rather, it directly connects to the 2nd host and send it the whole request using socket.  Actaully your script is acting as a browser.

This is not a simple approach of course.  You need to be familiar  with socket and http.
0
3 Use Cases for Connected Systems

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

 

Author Comment

by:tonysebion
ID: 1828689
ummm, exactly, that's just what i said - now does anyone have an example of that :)
0
 
LVL 5

Accepted Solution

by:
icd earned 200 total points
ID: 1828690
The answer I gave first does what you want.

Script 1. (your script) is modified so that it does not output any html itself.

If running on Windows NT (since you did not answer my query about the server) then you use the WinPerl::Internet module to send an http request to the URL of the second script. This will return the second page in a scalar variable which you can then print. I have a simple example of this which works.

If running UNIX then you need to write a socket program to connect to the URL of the second script. A little bit more complicated but the same principle as above.

The net (pun intentional) result is that the user clicks on a button on the first form, your script is run which runs the second script and the result of the second script is output to the user.
0
 
LVL 5

Expert Comment

by:icd
ID: 1828691
I have found a script that although it does not do exactly what you want it will show you how to use sockets to retrieve a URL (i.e. run the second script). I will continue to look for other more immediately relevent scripts but you might want to look at.

http://sunhe.jinr.dubna.su/docs/webcopy.html
0
 
LVL 5

Expert Comment

by:icd
ID: 1828692
An even better script to see socket programming in action is at:-

http://www.cfcl.com/tin/P/9606.nph-rover

0
 

Author Comment

by:tonysebion
ID: 1828693
that 2nd one looks like just the thing i need...if i need additional help on this, i'll just ask another question....
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Ever wondered how to display how many visitors you have online. In this tutorial I will show you an easy but effective way to display the number of online visitors in WhizBase. In this article I assume you have read my previous articles and know …
The viewer will learn how to count occurrences of each item in an array.
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…

919 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

23 Experts available now in Live!

Get 1:1 Help Now