Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

executing a webpage within a script 1

Status
Not open for further replies.

1DMF

Programmer
Joined
Jan 18, 2005
Messages
8,795
Location
GB
Hello,

I have found the answer to my PDF woes, only I have had to use an ASP solution.

The problem being our system is in PERL!

Is it possible to open an ASP page from perl without openeing a new browser window and capturing the returned output?

Thus I can dynamically create the .asp page, use perl to call it which will generate the PDF and then use PERL to attach the PDF to an email and send.

What module should I use to run the ASP, thanks

1DMF

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Glad you've found a solution.

LWP::Simple should do what you're looking for:
Code:
use LWP::Simple;

getstore( '[URL unfurl="true"]http://www.example.com/somescript.asp',[/URL] '/path/to/downloaded_file.pdf' );
 
thanks ishnid, though I'm a little confused with the second parameter?

'/path/to/downloaded_file.pdf'

What do I need this for? All I want is to open the ASP, the VBScript in the ASP creates the PDF, which I will then use PERL to attach to email

is there a test I can do on getstore to ensure PERL waits until the page is executed before continuing the script?


"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
The "getstore" function accesses a web page (in this case your ASP script) and saves what it gets back (in this case the generated PDF file) on the local filesystem. The second parameter is the filename to save it as (documentation here).

If you're using, for example, to send your mail, you can then attach your file like so:
Code:
       $msg->attach(Type => "application/pdf",
                     Path => "/path/to/downloaded_file.pdf",
                     Filename => "report.pdf");
 
sorry ishnid, I might not have been clear, but the ASP doesn't return a PDF, it also already saves the PDF to the server, I just want to call the ASP and wait till it runs, I'm actually not interested in anything returned from the ASP page, I just need it executed!

so what should I use LWP:Simple and get(URL) ?

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
No problem.

In that case, you can just use the "get" function to call the ASP script.
 
I'm having a problem, the LWP:Simple get(URL) method isn't working.

I don't get an error but I also don't get a PDF created, yet if I paste the same URL into a browser the ASP runs and the PDF gets executed.

any ideas why?

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Strange. If you print the output of "get", do you see what the ASP page should be outputting (i.e. whatever HTML is printed to the screen when the PDF is generated).

Are you using any sort of log-in to run the ASP? Or using a POST request?
 
No, however is it anything to do with the url being https ?

if I do this
Code:
my $content = get("$url");
 die "Couldn't get it!" unless defined $content;

I get the 'Couldn't get it!' printed, so it is failing to get the URL although it is valid.

does LWP:simple have problems with https ?

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
i'm having trouble finding the package via PPM, i'm using trouchelle , bribes and activestate repositories and the nearest I can find is Net_SSLeay , will this do?

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
actually I decided to not use https(SSL) , the files get deleted as soon as PERL has finished with them so it's no big deal!, everything works fine now I've moved it to non-https

thanks ishnid :-)

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Just to "complete the thread", so to speak: I don't actually know if Net::SSLeay will work with LWP. Would've been worth a shot if you hadn't solved it some other way. Glad you did. Cheers for the star :-)
 
mo probs ishnid you earned is as usual.

If I need https at some point i'll give Net_SSLeay a go and post back my results.

Until then , take it easy :-)

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top