Can anyone help me with a method of picking up a pdf from a variable url? ( like http:// ipadres/ordernr.pdf). With every new order, the url is changed
greetings
http pickup tool
-
- Newbie
- Posts: 17
- Joined: Mon Dec 13, 2010 4:52 pm
http pickup tool
dkelly wrote: Hello, I can help you.
Hi Dwight,
would U use a command line tool or just JS? Or is it a service you offer? Please let others also know how you could help.
Thank you,
Peter
Hi Dwight,
would U use a command line tool or just JS? Or is it a service you offer? Please let others also know how you could help.
Thank you,
Peter
-
- TOP CONTRIBUTOR
- Posts: 628
- Joined: Mon Nov 29, 2010 8:45 pm
- Location: Alpharetta GA USA
- Contact:
http pickup tool
I'd use a Switch Javascript to retrieve the remote document via wget command.
// HTTPget - retrieve file from remote web server
//
// Developed by Dwight Kelly <dkelly@apago.com>
// Copyright 2011 - Apago, Inc. -- All rights reserved
//
function jobArrived( s : Switch, job : Job )
{
// get filename to retreive
var String theURI = s.getPropertyValue("URI", job);
if (theURI.length == 0) {
job.fail("HTTPget: No URI specified!");
}
// create output file path
var slashPos = theURI.lastIndexOf( "/" );
var String outName = job.createPathWithName( theURI.substring( slashPos+1, theURI.length) );
var String args = new Array();
args[0] = "/opt/local/bin/wget";
args[1] = theURI;
args[2] = "-o";
args[3] = outName;
var myProc = new Process(args);
myProc.start();
myProc.waitForFinished(60);
if (myProc.exitStatus == 0) {
// success
job.sendToSingle(outName);
return;
}
job.fail("HTTPget failed!");
}
// HTTPget - retrieve file from remote web server
//
// Developed by Dwight Kelly <dkelly@apago.com>
// Copyright 2011 - Apago, Inc. -- All rights reserved
//
function jobArrived( s : Switch, job : Job )
{
// get filename to retreive
var String theURI = s.getPropertyValue("URI", job);
if (theURI.length == 0) {
job.fail("HTTPget: No URI specified!");
}
// create output file path
var slashPos = theURI.lastIndexOf( "/" );
var String outName = job.createPathWithName( theURI.substring( slashPos+1, theURI.length) );
var String args = new Array();
args[0] = "/opt/local/bin/wget";
args[1] = theURI;
args[2] = "-o";
args[3] = outName;
var myProc = new Process(args);
myProc.start();
myProc.waitForFinished(60);
if (myProc.exitStatus == 0) {
// success
job.sendToSingle(outName);
return;
}
job.fail("HTTPget failed!");
}
-
- Newbie
- Posts: 17
- Joined: Mon Dec 13, 2010 4:52 pm
http pickup tool
Just saw that PowerSwitch 09 has a comand to fetch files via http or ftp. So the script can be truncated and not relying on wget.
…
var String outName = job.createPathWithName( theURI.substring( slashPos+1, theURI.length) );
if ( s.download(theURI,outName) == true) {
// success
job.sendToSingle(outName);
return;
}
job.fail("HTTPget failed!");
…
Peter
…
var String outName = job.createPathWithName( theURI.substring( slashPos+1, theURI.length) );
if ( s.download(theURI,outName) == true) {
// success
job.sendToSingle(outName);
return;
}
job.fail("HTTPget failed!");
…
Peter