[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2782
  • Last Modified:

Perl CGI: simulate form post/get's in a script (set param('blah') values)

I want to set post/get parameters in a perl script with out doing a post/get.

I have a script that allows people to manipulate data in the QA environment... While doing so, their actions get recorded...

In the prod environment, I want to be able to go through the recorded actions and replicate them on prod in a semi-automated manner (like merging their changes to prod).  I don't want to write all new functions for this... I'd like to be able to just call my script with the same parameters as when they did it manually in QA.

So, I would need to set the param('key') values so that when each sub is called, I can set the param('blahblah') values so they are the same as when the person did it in QA.

Unless there is an easier way...  I just need to simulate multiple form submits basicaly without actually doing the submits...

thanks
0
jasonsbytes
Asked:
jasonsbytes
3 Solutions
 
TintinCommented:
I'm not really sure what you're trying to do.

1. What format are the actions in QA recorded?

2. When you say you what to simulate a form submit without actually doing the submit, do you mean you don't want the Perl/CGI script to actually do any thing with the parameters?
0
 
jasonsbytesAuthor Commented:
over in QA a user submits a form that posts data to a database...  There are many different forms and they may edit data, delete data, add new data using different forms.  This is all handled normally, form posts, cgi reads param('formkey'), does something with it, updates Oracle.

While all of that is happening, I'm recording arbitrary actions in a db.  Like 'added new blah record' with key 'blah' to table 'blah'.

There may be many of these actions for one 'session' or 'view' whatever you want to call it.

Then in prod, I want to loop through these actions, pull the data from the qa db associated with each action, call the same script with the same parameters and set the param('blah') values so the script does the same thing in prod as what the person did in qa.  

It will loop through many of these, setting and resetting param('keys') to match the actions...  I'm just trying to reuse code...  

Does that help?
0
 
jasonsbytesAuthor Commented:
If I assign a value to param('town'), does that work?

can i say:
param('town') = 'Huston';
without submitting a form with a textbox named 'town'?
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.

 
Adam314Commented:
If your forms use the GET method, you can use your log file in the QA environment to make the same requests in your prod environment.
If your forms use the POST method, the QA forms will have to save the post data somewhere, then the prod forms will have to get data from there.

If you are using the CGI module, it has options that allow it to get it's data from a file, instead of from the actual GET and POST data.  See here:
http://search.cpan.org/~lds/CGI.pm-3.29/CGI.pm#CREATING_A_NEW_QUERY_OBJECT_FROM_AN_INPUT_FILE
0
 
TintinCommented:
Why not just specify the parameters from the command line, eg:

/path/to/cgi-bin/script.cgi param1=value1 param2=value2

0
 
ahoffmannCommented:
> If I assign a value to param('town'), does that work?
param(-name=>'town',-value=>'foo');

But I don's see how this should help if you set the parameters in the script itself you don't need to use CGI either ...

> Then in prod, I want to loop through these actions,
do mean something like

wget http://your.tld/path/to/script?par1=val1&par2=val2
0

Featured Post

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now