SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
FTPFileExists

 
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite View previous topic
View next topic
FTPFileExists
Author Message
KevinH



Joined: 25 Jun 2007
Posts: 4
Country: Canada

Post FTPFileExists Reply with quote
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 View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7955

Post Reply with quote
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 View user's profile Send private message
KevinH



Joined: 25 Jun 2007
Posts: 4
Country: Canada

Post Reply with quote
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 View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7955

Post Reply with quote
You can do the following

Code:
OnErrorResumeNext
FileDir ... parameters here ...
OnErrorStop

Tue Jun 26, 2007 2:54 pm View user's profile Send private message
KevinH



Joined: 25 Jun 2007
Posts: 4
Country: Canada

Post Reply with quote
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 View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7955

Post Reply with quote
I suggest to change it as below

Code:
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 View user's profile Send private message
KevinH



Joined: 25 Jun 2007
Posts: 4
Country: Canada

Post Reply with quote
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 View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7955

Post Reply with quote
FTPFileExists is supposed to be working correctly in the latest release 3.4.27
Tue Jul 10, 2007 3:44 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
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


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.