Replacing Print Location..
Replacing Print Location..
am 16.08.2007 20:24:23 von 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
Re: Replacing Print Location..
am 17.08.2007 01:16:01 von Jim Gibson
In article <1187288663.883215.18030@w3g2000hsg.googlegroups.com>, Bill
H wrote:
> 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
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Re: Replacing Print Location..
am 17.08.2007 02:15:57 von Bill H
On Aug 16, 7:16 pm, Jim Gibson wrote:
> In article <1187288663.883215.18...@w3g2000hsg.googlegroups.com>, Bill
>
> H wrote:
> > 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
>
> Posted Via Usenet.com Premium Usenet Newsgroup Services
> ----------------------------------------------------------
> ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ----------------------------------------------------------
> http://www.usenet.com
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
Re: Replacing Print Location..
am 17.08.2007 06:04:15 von paduille.4061.mumia.w+nospam
On 08/16/2007 07:15 PM, Bill H wrote:
> [...]
> 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.
Re: Replacing Print Location..
am 17.08.2007 13:57:17 von 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&specval ue2=
$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&edit what=
$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
Re: Replacing Print Location..
am 17.08.2007 15:44:31 von Glenn Jackman
At 2007-08-17 07:57AM, "Bill H" wrote:
> 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)?
You might want to 'do other_prog.pl;'
--
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry
Re: Replacing Print Location..
am 17.08.2007 16:58:34 von Bill H
On Aug 17, 9:44 am, Glenn Jackman wrote:
> At 2007-08-17 07:57AM, "Bill H" wrote:
>
> > 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)?
>
> You might want to 'do other_prog.pl;'
>
> --
> Glenn Jackman
> "You can only be young once. But you can always be immature." -- Dave Barry
Glenn that works great!
Bill H