http pickup tool

Post Reply
sherczog
Newbie
Posts: 6
Joined: Wed Mar 23, 2011 3:43 pm

http pickup tool

Post 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
dkelly
TOP CONTRIBUTOR
Posts: 658
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

http pickup tool

Post by dkelly »

Hello, I can help you.



Dwight Kelly

Apago, Inc.

dkelly@apago.com

http://www.apago.com
Peter Kleinheider
Newbie
Posts: 17
Joined: Mon Dec 13, 2010 4:52 pm

http pickup tool

Post 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
dkelly
TOP CONTRIBUTOR
Posts: 658
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

http pickup tool

Post 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!");

}

Peter Kleinheider
Newbie
Posts: 17
Joined: Mon Dec 13, 2010 4:52 pm

http pickup tool

Post 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
Post Reply