GETLIST remote_dir extra characters

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

GETLIST remote_dir extra characters

Postby mark911mcc » 08 Nov 2011, 09:02

Hi,

I am a first time user of ScritpFTP....this is great....everything I need to make me feel like a real programmer, but....!

Below is the script I have created to identify if a directory exists with todays date ie 20111108 if not create it....

ftp script iconFTP Script: (script.ftp) [ Download ] [ Hide ]
#Check to see if directory with todays date exists if not create it
GETLIST($checkdir,REMOTE_DIRECTORIES,$currentdate)
PRINT($checkdir)
PRINT($currentdate)
# problem with returned directory list - leading character
IF($checkdir!="$currentdate")
        # Create directory with current date
        MKDIR($currentdate)
END IF


However the script returns...

GETLIST(REMOTE_DIRECTORIES,"20111108")
Getting directory listing of current remote directory
Found 1 directory.
|20111108
20111108


The GETLIST commend is putting a leading character and it therefore does not match the "$currentdate".

What can I do to fix this...

Also is there a way of changing the date format to DDMMYYYY.

Thanks

Mark....
mark911mcc
 
Posts: 4
Joined: 08 Nov 2011, 08:56

Re: GETLIST remote_dir extra characters

Postby ScriptFTP support » 16 Nov 2011, 14:51

Hello,

Welcome to the forum. You can try putting "|" before the date:

ftp script iconFTP Script: (sample.ftp) [ Download ] [ Hide ]
IF($checkdir!="|".$currentdate)
        # Create directory with current date
        MKDIR($currentdate)
END IF


But a better (and cleaner) way to see if the directory actually exists or not is:

ftp script iconFTP Script: (script.ftp) [ Download ] [ Hide ]
#Check to see if directory with todays date exists if not create it
$directory_to_find=GETTIME(FORMAT3)
$found="FALSE"
GETLIST($directory_list,REMOTE_DIRECTORIES)

FOREACH $directory IN $directory_list
     IF($directory==$directory_to_find)
          $found="TRUE"
     END IF
END FOREACH
ScriptFTP support
Site Admin
 
Posts: 624
Joined: 04 Aug 2008, 15:08
Location: Burgos, Spain, EU

Re: GETLIST remote_dir extra characters

Postby mark911mcc » 28 Nov 2011, 02:21

Thanks, I went with option A putting "|" in front. Because we are using the filetr option in the GETLIST and not using the rest of the directory listing it seams to be a much simpler fix.

Cheers

Mark....
mark911mcc
 
Posts: 4
Joined: 08 Nov 2011, 08:56


Return to Troubleshooting



Who is online

Users browsing this forum: No registered users and 1 guest

cron