Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Passing info from one cgi to another

Posted on 1999-07-13
13
Medium Priority
?
240 Views
Last Modified: 2010-05-18
Anyone know how to pass some text from one cgi to another ?

I have a cgi which accepts a password from a form then opens another cgi which is another form but on a different server.

I want to keep that password "live" and insert it into a hidden field on the other server as part of a form.

The first (and easiest) that works gets 100 points ;-)
0
Comment
Question by:boney
[X]
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
  • 4
  • 4
  • 2
  • +2
13 Comments
 
LVL 5

Expert Comment

by:prakashk021799
ID: 1214103
How do you invoke the second script?

You could save the password in an environment variable before invoking the second script.

Something like (in script 1):

$ENV{PASSWORD} = param('password');

# run the second cgi script here

In script 2:

# get the password
$password = $ENV{PASSWORD};

# get all the other CGI parameters

....


0
 
LVL 5

Expert Comment

by:prakashk021799
ID: 1214104
Oops! Never mind.

I didn't look at the part where you said the second script is on a different server.
0
 

Author Comment

by:boney
ID: 1214105
I was hoping I could do something simple like call the cgi and add ?field=something
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 5

Expert Comment

by:prakashk021799
ID: 1214106
You could do that but the password would then be part of the URL for the second script. I thougth you wanted to avoid that. If that's not a problem you already got your solution.

If you don't want the password to show up in the URL, then you would need to use the POST method to send the parameter values for the second script. You can use LWP::UserAgent module for this. In the second script read the values from STDIN (If you use CGI.pm, this part is automatically done for you).

Then script 1 would be some thing like:

use LWP::UserAgent;
use HTTP::Request::Common;

$ua = new LWP::UserAgent;
## Assuming $password has the value you have already read from the user
$ua->request(POST 'http://somewhere/script2.cgi', [ PASSWORD => $password]);
# check the response etc.

In script 2:

use CGI.pm qw(:standard);

$password = param('PASSWORD');

0
 

Author Comment

by:boney
ID: 1214107
Hmm

I do have those modules but I don't really call the script as such as it is just a url I load (I think )  :-)

the first script checks that the password is valid then chooses a url from a list to send them to which is then loaded but the url is hidden by the validate cgi...

does that help ?
0
 
LVL 2

Expert Comment

by:helver
ID: 1214108
What you might be able to do is to construct an HTML frameset with only one
frame, that takes up the entire window.  Then, load the URL you want with the ?pass=passwd tacked onto the end.  

I think putting in a frame will sufficiently obscure the URL.

So essentially:

print "Content-type: text/html\n\n";
print "<html><head><title>Validated Page</title></head>";
print "<frameset cols="*"><frameset rows="*">";
print "<frame src="http://other.server.org/cgi.cgi?pass=passwd">";
print "</frameset></frameset></html>";
0
 
LVL 84

Expert Comment

by:ozo
ID: 1214109
or <input type=hidden> like boney asked for
0
 
LVL 2

Expert Comment

by:helver
ID: 1214110
Aw, damn...  I hope it wasn't really that simple...
0
 
LVL 2

Expert Comment

by:tpryor
ID: 1214111
print("Location: http://www.somewhere.com/script2.cgi?pwd=$password");

this will redirect to another web page and pass the pwd var.
the other script must be set up to recieve this var in the usual way.

t
0
 
LVL 2

Expert Comment

by:tpryor
ID: 1214112
oops forgot the newline charecters should be

print("Location: http://www.somewhere.com/script2.cgi?pwd=$password\n\n");
0
 

Author Comment

by:boney
ID: 1214113
I am going to accept prakashk's answer (if he proposes it) as it was the nearest to what actually worked !

prakashk ?
0
 
LVL 5

Accepted Solution

by:
prakashk021799 earned 300 total points
ID: 1214114
> I am going to accept prakashk's answer (if he proposes it) as it was the
> nearest to what actually worked !

Ok. I am posting it again as answer.


If you don't want the password to show up in the URL, then you would need to use the POST method to send the parameter values for the second script. You can use LWP::UserAgent module for this. In the second script read the values from STDIN (If you use CGI.pm, this part is automatically done for you).

Then script 1 would be some thing like:

       use LWP::UserAgent;
       use HTTP::Request::Common;

       $ua = new LWP::UserAgent;
       ## Assuming $password has the value you have already read from the user
       $ua->request(POST 'http://somewhere/script2.cgi', [ PASSWORD => $password]);
       # check the response etc.

In script 2:

       use CGI.pm qw(:standard);

       $password = param('PASSWORD');
0
 

Author Comment

by:boney
ID: 1214115
Thanks guys !
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

722 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