On Wednesday 21 July 2004 HH:44:20, David Arnold wrote:
> Phillip,
Hi David,
please bottom post.
>
> Thanks, but this is not quite what I was looking for.
>
> When the user clicks on "Quiz1" a perl script will be called to generate
> and compile a tex file using pdflatex. Once that is complete, I will have a
> file Quiz1.pdf which I want to send back to the user.
maybe I don't get it, but I think the base principle stays the same - as long
as you specify the correct http content-type, you can to what you want before
sending it back to the user, and the user will receive your script's output
as a file (i.e. the browser should ask the user if it wants to open or save
the file etc.). It should be transparent to the user whether a file is
returned by the web server directly or if you create it on the fly.
Let me re-write the example (untested, again):
#!/usr/bin/perl -w
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use FileHandle;
my $query = new CGI();
print $query -> header(-type => 'text/plain');
# call an external program to generate a file
system('netstat > netstat.file')
or die "could not call netstat : $!";
# open the file and sent it back to the user
my $fh = new FileHandle();
open($fh, 'netstat.file')
or die "could not open netstat file : $!";
while (<$fh>) {
print;
}
close($fh)
or die "could not close handle to netstat file : $!";
If I'm on the wrong track, let me know - otherwise this should do the trick.
HTH,
Philipp
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>