We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

linking two cgi scripts

tonysebion
tonysebion asked
on
Medium Priority
244 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

Comment
Watch Question

icd

Commented:
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.
icd

Commented:
Sorry, that should read 'The best approach might be to re-write the *first* script'

Author

Commented:
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.....


Commented:
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.

Author

Commented:
ummm, exactly, that's just what i said - now does anyone have an example of that :)
Commented:
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.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
icd

Commented:
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
icd

Commented:
An even better script to see socket programming in action is at:-

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

Author

Commented:
that 2nd one looks like just the thing i need...if i need additional help on this, i'll just ask another question....
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.