Hello *,
I must make an FTP-Access to an remote Server.
The FTP-Provider provide for a normal File a separate .ok-File. If this .ok-File exist it´s "safe" to download the normal file, e.g:
File1.txt
File1.txt.OK
After the download is ended normally, both files should be deleted.
How can I handle this with scriptFTP?
Kindly regards
Marc
I must make an FTP-Access to an remote Server.
The FTP-Provider provide for a normal File a separate .ok-File. If this .ok-File exist it´s "safe" to download the normal file, e.g:
File1.txt
File1.txt.OK
After the download is ended normally, both files should be deleted.
How can I handle this with scriptFTP?
Kindly regards
Marc
Hello Marc,
There is a script sample at http://www.scriptftp.com/examples.php?g ... delete.ftp that performs a very similar task. All you have to do is to find this chunk:
There is a script sample at http://www.scriptftp.com/examples.php?g ... delete.ftp that performs a very similar task. All you have to do is to find this chunk:
Code: Select all
And change it to this:# Get the remote file listing, store it in $list
$result=GETLIST($list,REMOTE_FILES,"*.txt")
Code: Select all
If you need further assistance don't hesitate to post a message here.# Get the remote file listing, store it in $list
$result=GETLIST($list,REMOTE_FILES,"*.OK")
liked Script FTP? Try our other product Email Parser
Hello,
thank yout for the help.
But If I change it to:
So in this case I must have a function like:
if $item.OK exist then download $item and $item.OK
Is this possible?
Greetings Marc
thank yout for the help.
But If I change it to:
Code: Select all
only the OK-Files will be downloaded. I tested it with these functions:$result=GETLIST($list,REMOTE_FILES,"*.OK")
Code: Select all
This works great, but FTPScript will download all files, generally! But I have the problem, that I have to wait for the OK-File to download the DATA- and the OK-File. # For each file in $list...
FOREACH $item IN $list_ok
# Download the file
$result_ok=GETFILE($item)
# If the file has been succesfully downloaded
  # delete the remote copy. If not stop the script.
IF($result_ok=="OK")
DELETEFILE($item)
ELSE
STOP
END IF
END FOREACH
FOREACH $item IN $list_txt
$result_txt=GETFILE($item)
IF($result_txt=="OK")
 DELETEFILE($item)
ELSE
 STOP
END IF
END FOREACH
So in this case I must have a function like:
if $item.OK exist then download $item and $item.OK
Is this possible?
Greetings Marc
Hello *,
I tested it now wiith following function:
Kindly regards
Marc
I tested it now wiith following function:
Code: Select all
So "Not Equal" is in that case the normal statemen, because the file will differ in the extension (file1.txt, file1.txt.ok). I don´t know the filenames, only the extension! $result_ok=GETLIST($list_ok,REMOTE_FILES,"*.ok")
$result_txt=GETLIST($list_txt,REMOTE_FILES,"*.txt")
IF ($list_ok==$list_txt)
GOTO :download
ELSE
PRINT("NOT EQUAL")
GOTO :end
END IF
Kindly regards
Marc
Hello Marc,
http://www.scriptftp.com/ScriptFTP_3_0_setup_devel.exe
I've just added to ScriptFTP two new commands (TEXTCUT and TEXTLENGTH) that are used to remove the trailing ".OK" from the variable that contains the file name. This new value is used to download the corresponding file.
So "Not Equal" is in that case the normal statemen, because the file will differ in the extension (file1.txt, file1.txt.ok). I don´t know the filenames, only the extension!Ok. Now I understand what you want. Install ScriptFTP again from this URL:
http://www.scriptftp.com/ScriptFTP_3_0_setup_devel.exe
I've just added to ScriptFTP two new commands (TEXTCUT and TEXTLENGTH) that are used to remove the trailing ".OK" from the variable that contains the file name. This new value is used to download the corresponding file.
Code: Select all
Please, post any thought or result you may have.# This script piece gets the remote file listing and downloads a
# file only if it exists also a remote file with the same file name
# with a trailing ".OK". For example, for this remote file listing:
#
# 1234.txt
# abcd.zip
# 1234.txt.OK
#
# Only 1234.txt along with 1234.txt.OK will be downloaded and
# deleted from the remote site.
#
$result=GETLIST($list,REMOTE_FILES,"*.OK")
IF($result!="OK")
STOP
END IF
# For each file in $list...
FOREACH $item IN $list
# get the number of characters of the file name
# ***** Warning! The TEXTLENGTH command does not
# work in the 3.0 version available under the download
# section of the website. Read the complete conversation.
$item_number_of_characters=TEXTLENGTH($item)
# Remove the ".OK" from the file name
# ***** Warning! The TEXTCUT command does not
# work in the 3.0 version available under the download
# section of the website. Read the complete conversation.
$file_to_download=TEXTCUT($item,1,$item_number_of_characters-3)
# Download the file
$result=GETFILE($file_to_download)
IF($result=="OK")
# Download successful, delete the remote file
DELETEFILE($file_to_download)
ELSE
STOP
END IF
# Download also the file with the trailing ".OK"
$result=GETFILE($item)
IF($result=="OK")
# Download successful, delete the remote file
DELETEFILE($item)
ELSE
STOP
END IF
END FOREACH
liked Script FTP? Try our other product Email Parser
Many, many, many thanks. That´s exactly what I need. With your Example-Script it works perfectly!
Kindly Regards
Marc
Kindly Regards
Marc
I just got ScriptFTP today and posted a request on the Wanted Features forum, but this looks like server code to me.
I can do code in this form but I am running it on my XP machine to make sure I always have the files on the server on my machine.
Is this an Advanced Server Side .ftp Coding Format?
Or can I use it on my home XP end?
It's the variables that are throwing me off.
All I know is, if I can program sFTP on my end based on more than just exact date, like on file size, and make some logical IF/THEN decessions that would be great.
I can do code in this form but I am running it on my XP machine to make sure I always have the files on the server on my machine.
Is this an Advanced Server Side .ftp Coding Format?
Or can I use it on my home XP end?
It's the variables that are throwing me off.
All I know is, if I can program sFTP on my end based on more than just exact date, like on file size, and make some logical IF/THEN decessions that would be great.
The Front Door to my multi-site server.
- All times are UTC -