 |
SoftTree Technologies
Technical Support Forums
|
|
Author |
Message |
KevinH
Joined: 25 Jun 2007 Posts: 4 Country: Canada |
|
FTPFileExists |
|
Hello,
I've got a script that uses the FTPFileExists command. When it finds a specific file, I delete the file using FTPFileDelete.
The problem is, FTPFileExists is returning a "true" value even though the file does not exist. When FTPFileDelete executes, it doesn't find the file in question and the job goes into error.
I can put in some garbage name for FTPFileExists and it'll still return a true value.
I've used this command ok in the past, I don't know why it's behaving this way now. Any ideas?
|
|
Mon Jun 25, 2007 11:47 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7955
|
|
|
|
This is actually a known issue, when 24x7 is used with some types of FTP servers, the FTPFileExists always returns true for any file in non-current directory.
One of the workarounds for that issue is to use FTPDir which appears to work reliable. If FTPDir returns an empty string then the file doesn't exists.
|
|
Mon Jun 25, 2007 6:51 pm |
|
 |
KevinH
Joined: 25 Jun 2007 Posts: 4 Country: Canada |
|
|
|
What I'm trying to do is write a script that checks an FTP server every 5 mins for a "DAILY" file, and if it's there, deletes it and kicks off some other jobs.
I can use the FTPDir command and use the filemask "DAILY", but if the file is not there then it goes into error.
Should I just get the whole directory list (it's pretty long) and parse it to find this file called "DAILY"?
Is this is best/only way because FTPFileExists is buggy?
|
|
Tue Jun 26, 2007 2:14 pm |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7955
|
|
|
|
You can do the following
 |
 |
OnErrorResumeNext
FileDir ... parameters here ...
OnErrorStop |
|
|
Tue Jun 26, 2007 2:54 pm |
|
 |
KevinH
Joined: 25 Jun 2007 Posts: 4 Country: Canada |
|
|
|
Thanks for your help. I've got the final logic down now. Here's my sample testing code. For any other users experiencing the same problem. I'm sure it's not the most efficient, but it works.
Dim a, string, ""
Dim b, string, ""
Dim test, boolean
OnErrorResumeNext
FTPDir ( "ftpserver.com", "username", "password", "DAILY", a )
IsEqual ( a, b, test )
If ( test, Leave, Execute1 )
Execute1:
Exit
Leave:
Exit
If the file "DAILY" is not there, the script exits gracefully. If the "DAILY" file is there, then we can start executing other commands because we know it exists.
|
|
Tue Jun 26, 2007 4:14 pm |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7955
|
|
|
|
I suggest to change it as below
 |
 |
Dim files, string
Dim not_found, boolean
OnErrorResumeNext
FTPDir ( "ftpserver.com", "username", "password", "DAILY", files )
OnErroStop
IsEqual ( files, "", not_found )
IfThen( not_found, Done)
.. do here what is needed ...
Done: |
|
|
Tue Jun 26, 2007 6:35 pm |
|
 |
KevinH
Joined: 25 Jun 2007 Posts: 4 Country: Canada |
|
|
|
I got one thing wrong in my sample code and one peculiar thing I noticed with 24x7.
In the FTPDir statement, you need to use a wildcard to maintain a NULL value. So for example:
FTPDir ( "ftpserver.com", "username", "password", "DAIL?", files )
That way the variable "files", will remain NULL.
If you use the specific filename like "DAILY", 24x7 will set the variable "files" to the value "DAILY: No such file or directory".
|
|
Wed Jun 27, 2007 10:57 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7955
|
|
|
|
FTPFileExists is supposed to be working correctly in the latest release 3.4.27
|
|
Tue Jul 10, 2007 3:44 pm |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|