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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FTP command example 3

Status
Not open for further replies.

DanLS

Programmer
Dec 21, 2005
4
US
Does anyone have an example of a working FTP command used within a PUT function?
Thanks!
 
valid(PUT("FTP", "-URL ftp://" + User + ":" + Pword + "@" + IPadd + "/Batch" + left(reversebyte(word(reversebyte(getresourcename(FTPOK)),"\",1)),8) + "/" + left(reversebyte(word(reversebyte(getresourcename(FTPOK)),"\",1)),8) + "confirm.txt" + " -MKD -T", package(confirm.txt)),fail("ftp confirm.txt failed " + TEXT ( LASTERRORCODE ( ) ) + " " + LASTERRORMSG()))
 
However, since PUT has almost no error handling, it is suggested that you use a RUN map call instead. Set the RUN map's target to file and on error commit.



BocaBurger
<===========================||////////////////|0
The pen is mightier than the sword, but the sword hurts more!
 
=valid(run("ftpadapter",echoin(1, confirm.txt) + " -OAFTP1 '-URL ftp://" + User + ":" + Pword + "@" + IPadd + "/" + Destination + "confirm.txt" + " -MKD -T+'"),fail("ftp confirm.txt failed " + TEXT ( LASTERRORCODE ( ) ) + " " + LASTERRORMSG()))

User, Pword, IPadd and Destination are input paremeters.
 
Remember to take out the -T+ for production.
The -MKD might not be needed.

Good rule for calling a general blob to blob map. Allows any map to have an common FTP information input tree so each FTP needed does not have to be redeveloped. Janhes should get a raise.



BocaBurger
<===========================||////////////////|0
The pen is mightier than the sword, but the sword hurts more!
 
Boca,

If one were to just do a plain FTP, no tracing, audit etc., wouldn't the FTP adapater on the command line be better than sinking with map rules? Faster?
 
PUT is the problem. If you have fixed FTP parameters, use the card tartget, if you have variables, use the RUN command and card over-rides. Only use PUT when nothing else would work. PUT has limited error handling and things can fail but not show an error.



BocaBurger
<===========================||////////////////|0
The pen is mightier than the sword, but the sword hurts more!
 
I see. The only variables I have are retries. Both can be set either on the IFD card level or the run command overides, so which uses more resources? I'm asking because I have to send about 3,000 files to a TP with a shady server and want to minimize resources.
 
RUN map takes a bit more resources, so a card target would do it, unless you are creating the data in a functional map. Then the RUN call would be from the Functional map. This can create problems if you are send ing all 3000 at one time, since the map does not actually send anything until the map completes and we issues the commit.

Better way in this case would be to use a PUT(FILE) with a unique name and trigger from the file to map that does the FTP.



BocaBurger
<===========================||////////////////|0
The pen is mightier than the sword, but the sword hurts more!
 
I see. I'm learning from you to try to make things as efficient as possible, as the bad code can keep haunting.


On card target, does it matter if I specify -Port? Or is Passive Mode default even if I specify -Port?
 
I believe the default ftp port is 21 so if thats the port you need you shouldn't have to state it.

Give it a try.
 
Ps: I agree, using the put function has minimal error handling....

We have some old maps that use it though.... Rather than rewrite the whole map I forced the trace file names then use a map to cinfirm the status.

Also, you should be able to perform an ftp DIR/LS to confirm the ftp success/failure.

All less than ideal but depending on your sit and you are not be able to implement Boca's suggestion....

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top