Uploading works, deleting wrong files.

Post here if you experience file transfer problems or unexpected errors.

Uploading works, deleting wrong files.

Postby Fortississimo » 18 Jan 2012, 10:00

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 iconFTP Script: [ Download ] [ Hide ]
# Get the local file listing, store it in $list
$result=GETLIST($list,LOCAL_FILES,"*.edi")
 
# If GETLIST failed stop the script
IF($result!="OK")
    STOP
END IF
 
# For each file in $list...
FOREACH $item IN $list
        # Upload the file
        $result=PUTFILE($item)
        # If the file has been succesfully uploaded
        # delete the local copy of the file
        IF($result=="OK")
                DELETEFILE($item)
        END IF
END FOREACH
 
Fortississimo
 
Posts: 3
Joined: 18 Jan 2012, 09:46

Re: Uploading works, deleting wrong files.

Postby Bucket » 19 Jan 2012, 03:43

Bucket
 
Posts: 27
Joined: 08 Feb 2011, 06:51

Re: Uploading works, deleting wrong files.

Postby Fortississimo » 19 Jan 2012, 09:15

Thanks for your reply :)

That seemed indeed to be the issue, I found that last night as well and edited that.
ftp script iconFTP Script: [ Download ] [ Hide ]
# For each file in $list...
FOREACH $item IN $list
        # Upload the file
        $result=PUTFILE($item)
        # If the file has been successfully uploaded
        # delete the local copy of the file
        IF($result=="OK")
                EXEC("del ".$item)
        END IF
END FOREACH
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.
Fortississimo
 
Posts: 3
Joined: 18 Jan 2012, 09:46

Re: Uploading works, deleting wrong files.

Postby Bucket » 20 Jan 2012, 05:39

Could you post your entire script?

There must be lines missing as the script you have shown cannot possibly produce the log output.
Bucket
 
Posts: 27
Joined: 08 Feb 2011, 06:51

Re: Uploading works, deleting wrong files.

Postby Fortississimo » 20 Jan 2012, 09:34

Sure, this is the complete script, blurred out some info obviously and left out some commentary.

ftp script iconFTP Script: [ Download ] [ Hide ]
# Set system variables
$date=GETDATE(YEAR).GETDATE(MONTH).GETDATE(DAY)
# -- enable this line (and disable one above by ##) if you want to see extended date & time :
## $date=GETDATE(YEAR).GETDATE(MONTH).GETDATE(DAY)."_".GETDATE(HOUR).GETDATE(MIN).GETDATE(SEC)

# my variables
$log_dir="D:\EDIGAS logging\LOGFILES"
$log_file=$log_dir."\EDIGAS Upload_".$date.".log"

# Start logging
VERBOSE(ON)
LOGTO($log_file,APPEND)

# Connect to EDIGAS FTP
PRINT("_____Verbinden met FTP ftp.bla.com_____")
$result=OPENHOST("ftp.bla.com","*******","*******")
$result=CHDIR("\EDI\send\import")
 
# If OPENHOST failed, stop the script
IF($result!="OK")
    STOP
END IF
 
# Change working directory
$result=LOCALCHDIR("D:\FCS\MECOMS\Production\EDI\Folders\XML2EDI\GAS_OUT")
 
# If LOCALCHDIR failed stop the script
IF($result!="OK")
    STOP
END IF
 
# Get the local file listing, store it in $list
$result=GETLIST($list,LOCAL_FILES,"*.edi")
 
# If GETLIST failed stop the script
IF($result!="OK")
    STOP
END IF
 
# For each file in $list...
FOREACH $item IN $list
        # Upload the file
        $result=PUTFILE($item)
        # If the file has been successfully uploaded
        # delete the local copy of the file
        IF($result=="OK")
                EXEC("del ".$item)
                EXEC("move ".$item.".metadata D:\FCS\MECOMS\Production\EDI\Folders\XML2EDI\GAS_OUT\processed")
        END IF
END FOREACH
PRINT("_____All done, closing connection_____")
 
# Close the connection
CLOSEHOST
PRINT ("_____Connection Closed_____")
Fortississimo
 
Posts: 3
Joined: 18 Jan 2012, 09:46


Return to Troubleshooting



Who is online

Users browsing this forum: No registered users and 0 guests

cron