ftp automation

ScriptFTP

The professional tool to automate FTP, SFTP, FTPS and schedule FTP batch jobs

The forum is now read only. Please, go to the the main ScriptFTP website if you need help.
Post here if you experience file transfer problems or unexpected errors.
Hello,

I have an upload script, that uploads certain files, and after uploading it deletes the file that is uploaded (from $List)
The upload goes well, but the deleting process not quite, it actually deletes the file from the FTP, whilst it should delete it locally.

What goes wrong here? Look to the upload/delete script below.

FTP Script
  1. # Get the local file listing, store it in $list
  2. $result=GETLIST($list,LOCAL_FILES,"*.edi")
  3.  
  4. # If GETLIST failed stop the script
  5. IF($result!="OK")
  6.     STOP
  7.  
  8. # For each file in $list...
  9. FOREACH $item IN $list
  10.     # Upload the file
  11.     $result=PUTFILE($item)
  12.     # If the file has been succesfully uploaded
  13.     # delete the local copy of the file
  14.     IF($result=="OK")
  15.         DELETEFILE($item)
  16.     END IF
Thanks for your reply :)

That seemed indeed to be the issue, I found that last night as well and edited that.
FTP Script
  1. # For each file in $list...
  2. FOREACH $item IN $list
  3.     # Upload the file
  4.     $result=PUTFILE($item)
  5.     # If the file has been successfully uploaded
  6.     # delete the local copy of the file
  7.     IF($result=="OK")
  8.         EXEC("del ".$item)
  9.     END IF
  10. PRINT("_____All done, closing connection_____")
It seems to work just fine, however I do wonder if I should worry about the log output scriptFTP gives(see red print):
PUTFILE("A_20120119_0224278.edi")
Uploading................. A_20120119_0224278.edi
DELE A_20120119_0224278.edi.part
550 File not found
PASV
227 Entering Passive Mode (xxx,xx,xx,xx,14,23)
Opening data connection to xxx.xx.xx.xx Port: 3607
STOR A_20120119_0224278.edi.part
150 Connection accepted
324 bytes transferred. (19,7 KB/s) (16 ms)
226 Transfer OK
DELE A_20120119_0224278.edi
550 File not found
RNFR A_20120119_0224278.edi.part
350 File exists, ready for destination name.
RNTO A_20120119_0224278.edi
250 file renamed successfully
CWD /EDI/send/import
250 CWD successful. "/EDI/send/import" is current directory.
PWD
257 "/EDI/send/import" is current directory.

EXEC("del A_20120119_0224278.edi")
_____All done, closing connection_____
The files do disappear locally though, so looks like it works, but maybe I've done something silly in the code what actually causes this.
Could you post your entire script?

There must be lines missing as the script you have shown cannot possibly produce the log output.
Sure, this is the complete script, blurred out some info obviously and left out some commentary.
FTP Script
  1. # Set system variables
  2. $date=GETDATE(YEAR).GETDATE(MONTH).GETDATE(DAY)
  3. # -- enable this line (and disable one above by ##) if you want to see extended date & time :
  4. ## $date=GETDATE(YEAR).GETDATE(MONTH).GETDATE(DAY)."_".GETDATE(HOUR).GETDATE(MIN).GETDATE(SEC)
  5.  
  6. # my variables
  7. $log_dir="D:\EDIGAS logging\LOGFILES"
  8. $log_file=$log_dir."\EDIGAS Upload_".$date.".log"
  9.  
  10. # Start logging
  11. VERBOSE(ON)
  12. LOGTO($log_file,APPEND)
  13.  
  14. # Connect to EDIGAS FTP
  15. PRINT("_____Verbinden met FTP ftp.bla.com_____")
  16. $result=OPENHOST("ftp.bla.com","*******","*******")
  17. $result=CHDIR("\EDI\send\import")
  18.  
  19. # If OPENHOST failed, stop the script
  20. IF($result!="OK")
  21.     STOP
  22.  
  23. # Change working directory
  24. $result=LOCALCHDIR("D:\FCS\MECOMS\Production\EDI\Folders\XML2EDI\GAS_OUT")
  25.  
  26. # If LOCALCHDIR failed stop the script
  27. IF($result!="OK")
  28.     STOP
  29.  
  30. # Get the local file listing, store it in $list
  31. $result=GETLIST($list,LOCAL_FILES,"*.edi")
  32.  
  33. # If GETLIST failed stop the script
  34. IF($result!="OK")
  35.     STOP
  36.  
  37. # For each file in $list...
  38. FOREACH $item IN $list
  39.     # Upload the file
  40.     $result=PUTFILE($item)
  41.     # If the file has been successfully uploaded
  42.     # delete the local copy of the file
  43.     IF($result=="OK")
  44.         EXEC("del ".$item)
  45.         EXEC("move ".$item.".metadata D:\FCS\MECOMS\Production\EDI\Folders\XML2EDI\GAS_OUT\processed")
  46.     END IF
  47. PRINT("_____All done, closing connection_____")
  48.  
  49. # Close the connection
  50. PRINT ("_____Connection Closed_____")