Page 1 of 1

http pickup tool

Posted: Wed Apr 06, 2011 4:03 pm
by sherczog
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

Posted: Wed Apr 06, 2011 9:26 pm
by dkelly
Hello, I can help you.



Dwight Kelly

Apago, Inc.

dkelly@apago.com

http://www.apago.com

http pickup tool

Posted: Mon Apr 11, 2011 2:39 pm
by Peter Kleinheider
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

http pickup tool

Posted: Mon Apr 11, 2011 3:34 pm
by dkelly
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!");

}


http pickup tool

Posted: Thu Apr 28, 2011 11:45 pm
by Peter Kleinheider
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