Check Return Code on FTPputFILE

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
alnatura
Newbie
Posts: 2
Joined: Mon Oct 13, 2003 3:48 pm

Check Return Code on FTPputFILE

Post by alnatura » Mon Oct 13, 2003 4:12 pm

We post different small ASCII-Files regularly on a ftp-server of our partners. Today the macro-scheduler-log file showed a correct FTPputFILE, but our partner didn´t receive the file. But our local macro continued to work and marked the file as "done". Of course our partners did not continue the work process! Bad luck.

To prevent this damage in the future I want to interpret the ReturnCode of the FTPputFILE-command. How can I do this?

thanks for your advice
wolfgang

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Mon Oct 13, 2003 4:45 pm

To confirm uploads with FTP, I have done a Directory listing of the FTP Server site after the upload and check for uploaded file. Here is an excerpt:
Label>Upload
//Upload file to FTP site
FTPPutFile>%FTPServer%,%FTPUser%,%FTPPW%,21,%ftpfilename%,%filename%,I

//Confirm upload to FTP
FTPGetDirList>%FTPServer%,%FTPUser%,%FTPPW%,21,%WorkDir%\FTPDir.txt,%filename%,L
Let>ftpfilesize=0
FileSize>%WorkDir%\FTPDir.txt,ftpfilesize
If>%ftpfilesize%>0,UploadOK
MessageModal>File not uploaded
//Loop for 5 attempts.
//...
Goto>Upload

Label>UploadOK
MessageModal>File %ftpfilename% was uploaded
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

alnatura
Newbie
Posts: 2
Joined: Mon Oct 13, 2003 3:48 pm

Using FTPGetFile afterwards also helps

Post by alnatura » Tue Oct 14, 2003 8:58 am

Hi,

I did not know about the FTPGetDirList-command - but it´s very nice to see that you had quite a similar idea to create a return code yourself. So the possibility to check the return code of the ftp-command would surely be helpful. But without this: since we upload numerous files and I have to check each file separately I did the following script:

------------------------------------------------
FTPPutFile>%cctop_server%,%cctop_user%,%cctop_pw%,%cctop_port%,%from_pathfile%,%cctop_pathfile%,%ftp_mode%
Wait>2
;
; check the success of the previous put
;
FTPGetFile>%cctop_server%,%cctop_user%,%cctop_pw%,%cctop_port%,%check_pathfile%,,%cctop_pathfile%%ftp_mode%
Wait>2
IfFileExists>%check_pathfile%,Success
;
; NO success
;
Let>MSG_STAYONTOP=1
GetDate>varDate
GetTime>varTime
LET>msg=The File %CRLF% %filename% %CRLF% was not found on ftp-server %CRLF% %varDate% - %vartime%
message>msg
Goto>EndOfLoop
;
; SUCCESS
;
Label>Success
...

-----------------------------------
This script is not very efficient since we do double transport via Internet. But up to now the file size is usually between 30 and 40 KBytes and I want to be very very sure that the file has been uploaded in time!

thanks for your Help Bob!

wolfgang

Lumumba

Post by Lumumba » Tue Oct 14, 2003 4:08 pm

Maybe you should have an additional look at the standard: FTP commands !

I guess a post file listing piped to a log.file should be save enough. That's what we're doing after pushing files to a customers server.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Wed Oct 15, 2003 1:47 am

Hi Lumumba....

I was trying to provide an answer using the Macro Scheduler FTP commands, but you are reminding us that that we can also use
Run Program>command /c ftp commands.

Thanks for the reminder about FTP commands and the listing.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts