Replacing Print Location..

B

Bill H

I have a perl script that process form inputs, saves the data and then
does a "print location: ..." to a different perl program that creates
pdf files from the saved data (using data passed in the url), and when
its done it does a "print location ..." to get back to the 1st
program. All these programs are on the same server and in the same
folder. The reason for 2 programs is that the the 2nd one loads a
number of support libraries for creating pdf's, handling images etc,
the 1st one is basically a form processor and information controller.
Instead of using this method, can I use an exec call? Would the
initial environment variables still be there?

Bill H
 
B

Bill H

Bill said:
I have a perl script that process form inputs, saves the data and then
does a "print location: ..." to a different perl program that creates
pdf files from the saved data (using data passed in the url), and when
its done it does a "print location ..." to get back to the 1st
program. All these programs are on the same server and in the same
folder. The reason for 2 programs is that the the 2nd one loads a
number of support libraries for creating pdf's, handling images etc,
the 1st one is basically a form processor and information controller.
Instead of using this method, can I use an exec call? Would the
initial environment variables still be there?

I am not proficient in HTTP, but it sounds to me as if you are
returning a Location response to the web browser from the first
submission, which requires the browser to send a second HTTP request to
your second program (I don't believe the server will figure out that
the Location redirect is to itself), which returns a Location response
to the browser, which then sends a third HTTP request to the server to
the first script. Right?

Why don't you just combine the two programs and save two rounds of
request-response.

--
Jim Gibson


----------------------------------------------------------

----------------------------------------------------------
color]

Jim

Thats exactly what it is doing. The reason for not combining them is
the middle program uses a lot of libraries to build pdf files and
process images. This is a lot of overhead I don't need in the other
program which is basically a form handler that saves data in a
particular file based on the user (well it does a lot of other web
based stuff). I suppose I could eliminate the 1st call by including
the data saving in the middle program and then it would only be 2
"Print Location"s.

What I would like best is to do something that I used to do back in my
Basic programming days on CP/M machines, when done with one program,
chain to another and have the variables stay intact. In the case of
Perl I would just want to be able to access the same Env values that
the 1st program that was called by the user access (ie form data,
cookies etc) in place of the variables staying intact as was done on
the old Basic programs.

I hope this makes since.

Bill H
 
M

Mumia W.

[...]
What I would like best is to do something that I used to do back in my
Basic programming days on CP/M machines, when done with one program,
chain to another and have the variables stay intact. In the case of
Perl I would just want to be able to access the same Env values that
the 1st program that was called by the user access (ie form data,
cookies etc) in place of the variables staying intact as was done on
the old Basic programs.

I hope this makes since.

Bill H

This last part (almost) sounds like a job for "exec": perldoc -f exec

However, you would have to explicitly place the form values and cookies
into the environment. If you're using CGI, the QUERY_STRING is already
in the environment.

The procedure would be to do some processing and place the form values
and cookies into the environment, then exec() the other
script--replacing the current script's code with the new script while
maintaining the data in the environment.

Data stored in Perl variables would be destroyed, so saving into the
environment (or somewhere else) is required with this method.
 
B

Bill H

I am not proficient in HTTP, but it sounds to me as if you are
returning a Location response to the web browser from the first
submission, which requires the browser to send a second HTTP request to
your second program (I don't believe the server will figure out that
the Location redirect is to itself), which returns a Location response
to the browser, which then sends a third HTTP request to the server to
the first script. Right?

Jim - I was just testing the programs and it appears that my server
may be handling the Print Location. Watching the address line closely
in the browser it never changes till it is done, then it displays the
final program.

FYI here is what the 1st Print Location in program 1 looks like:

print qq~Location: /system/editor/makepdf.pl?project=
$thisproject&folder=$thisfolder&id=$thischapter&whatproject=
$curproject&special=photopage&specvalue1=$updatewhat&specvalue2=
$photolayout\n\n~;


Then the 2nd program (makepdf.pl) uses this one to go back to the 1st
program:

print qq~Location: /system/project.pl?project=
$thisproject&action=editchapter&whatproject=$curproject&editwhat=
$thischapter\n\n~;

So technically I suppose I do not need the Env data in the 2nd program
(or re-running of the 1st program) since all the information needed is
on the command line.

I am wondering, instead considering using exec to run this instead of
the print Location, would it be better to use a system() call? That
way I dont need to have it re-run program 1 when 2 is done, it will
just wait for program 2 to finish and carry on? Is there any drawbacks
to using a system() call to run another perl program (memory, speed
etc)?

Any and all advise is always welcome

Bill H
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top