SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
Problem FTPFileExists

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



Joined: 02 Sep 2004
Posts: 11

Post Problem FTPFileExists Reply with quote


I am trying to run the following script but am having
trouble with FTPFileExists. It returns true whether
the file exist or does not exist. I am run version
3.4.24 on a Win2000 PC. The FTP location is on a
Unix box. I have tried checking the root and to a
subdirectory but it always returns true. I have
check the target location and verified that the
file does not exist. I have run this in normal mode
and debug mode. Is there something I am doing wrong.

Thank you,
Norm James

// This program looks for all ROC*.DAT file in the Release directory and FTPs them one by one
// to the FTP Target location. It then move the file to the Archive directory.
// Created by NWJ 5/11/2005

Dim file_found, boolean
Dim SLoc, string
Dim SFile, String
Dim Source_file, string
Dim Target_Loc, string
Dim TargetFile, string
Dim TargetArch_Loc, string
Dim TargetArch_File, string
Dim ArchiveLoc, string
Dim ErrorLog, string
Dim NotSentLoc, string
Dim LogFIle, string
Dim NumOfArch, number
dim FileName, string
Dim FTPAcct, string
Dim FTPUser, string
Dim FTPPw, string
dim FoundFile, string
dim file_number, number
Dim FF, boolean
dim Line, string
dim File1, string
Dim File2, string
Dim I, Number
Dim J, number
Dim NotFound, boolean
Dim current_time, time
Dim current_date, date
Dim start_time, datetime
dim found, boolean

IniFileGetKey "c:\progs\PeoplesoftRel.ini", "FTP", "ACCT", FTPAcct
IniFileGetKey "c:\progs\PeoplesoftRel.ini", "FTP", "USER", FTPUser
IniFileGetKey "c:\progs\PeoplesoftRel.ini", "FTP", "PASSWORD", FTPPw
IniFileGetKey "c:\progs\PeoplesoftRel.ini", "FILES", "TARGET", Target_Loc
IniFileGetKey "c:\progs\PeoplesoftRel.ini", "FILES", "TARGETARCHIVE", TargetArch_Loc
IniFileGetKey "c:\progs\PeoplesoftRel.ini", "FILES", "SOURCELOC", SLOC
IniFileGetKey "c:\progs\PeoplesoftRel.ini", "FILES", "SOURCEFILE", SFile
IniFileGetKey "c:\progs\PeoplesoftRel.ini", "FILES", "ARCHIVELOC", ArchiveLoc
IniFileGetKey "c:\progs\PeoplesoftRel.ini", "FILES", "ERRORFILE", ErrorLog
IniFileGetKey "c:\progs\PeoplesoftRel.ini", "FILES", "LOGFILE", LogFile
IniFileGetKey "c:\progs\PeoplesoftRel.ini", "FILES", "NOTSENTLOC", NotSentLoc

concat SLoc, SFile, Source_file

// Start file search
FileFindFirst( Source_file, FileName, found )
LoopWhile( found, ENDLOOP )

ConcatEx( SLoc, FileName, FoundFile )

Concat( Target_Loc, FileName, TargetFile )

Concat( TargetArch_Loc, FileName, TargetArch_File )

FTPConfig( "Transfer Mode", "ASCII" )

OnErrorGoTo FTP_ERR1

//If file found in IN Log Error
// FTPFileExists( FTPAcct, FTPUser, FTPPw, TargetFile, file_found )

FTPFileExists( FTPAcct, FTPUser, FTPPw, FileName, file_found )

if( file_found, LOG_FOUND_ERR, CHECK_BKP )

CHECK_BKP:

//If file found in BKP Log Error

FTPFileExists( FTPAcct, FTPUser, FTPPw, TargetArch_File, file_found )

if( file_found, LOG_FOUND_ERR, OK_TO_SEND )

LOG_FOUND_ERR:

// Get time

Today( current_date )

Now( current_time )

DateTime( current_date, current_time, start_time )

// Build text line

Concatex( start_time, ": ", FileName, " - File Found in FTP Area. ", line )

Concat( line, " File May have been sent before.", line )

Concat( line, " Moving it to Hold Directory.", line )

// Append to Error log file

FileOpen( ErrorLog, "LineMode", "Write", TRUE, file_number )

FileWrite( file_number, line )

FileClose( file_number )

// Moves file to the Not Sent Folder

concat NotSentLoc, FileName, File2

OnErrorGoTo FTP_ERR2

FileMove( FoundFile, file2 )

OnErrorResumeNext

goto NEXT_FILE

OK_TO_SEND:

OnErrorGoTo FTP_ERR1

FTPPutFile( FTPAcct, FTPUser, FTPPw, FoundFile, TargetFile )

FTPFileExists( FTPAcct, FTPUser, FTPPw, TargetFile, file_found )

OnErrorResumeNext

//If file found Log OK file

if( file_found, FILE_SENT_OK, FILE_ERR )

FILE_ERR:

// Get time

.

.

OnErrorResumeNext

goto NEXT_FILE

FILE_SENT_OK:

// Get time

.

.

NEXT_FILE:

// Find next file

FileFindNext( FileName, found )
ENDLOOP:
exit

FTP_ERR1:

// Append to Error log file

goto end_job

FTP_ERR2:

// Get time

End_Job:

exit

Thu Jun 16, 2005 1:33 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7975

Post Re: Problem FTPFileExists Reply with quote

First of all check if your Windows Internet settings don't have file caching enabled (click Control Panel, click Internet Options, in Temporary Internet Files box click Settings button, make sure "Every visit to the page..." option is checked. If not, checked, apply changes and restart 24x7.

If that does not help, please provide an example of a full file name that you trying to check using FTPFileExists command.

: I am trying to run the following script but am having
: trouble with FTPFileExists. It returns true whether
: the file exist or does not exist. I am run version
: 3.4.24 on a Win2000 PC. The FTP location is on a
: Unix box. I have tried checking the root and to a
: subdirectory but it always returns true. I have
: check the target location and verified that the
: file does not exist. I have run this in normal mode
: and debug mode. Is there something I am doing wrong.

: Thank you,
: Norm James

: // This program looks for all ROC*.DAT file in the Release directory and FTPs
: them one by one
: // to the FTP Target location. It then move the file to the Archive
: directory.
: // Created by NWJ 5/11/2005

: Dim file_found, boolean
: Dim SLoc, string
: Dim SFile, String
: Dim Source_file, string
: Dim Target_Loc, string
: Dim TargetFile, string
: Dim TargetArch_Loc, string
: Dim TargetArch_File, string
: Dim ArchiveLoc, string
: Dim ErrorLog, string
: Dim NotSentLoc, string
: Dim LogFIle, string
: Dim NumOfArch, number
: dim FileName, string
: Dim FTPAcct, string
: Dim FTPUser, string
: Dim FTPPw, string
: dim FoundFile, string
: dim file_number, number
: Dim FF, boolean
: dim Line, string
: dim File1, string
: Dim File2, string
: Dim I, Number
: Dim J, number
: Dim NotFound, boolean
: Dim current_time, time
: Dim current_date, date
: Dim start_time, datetime
: dim found, boolean

: IniFileGetKey "c:\progs\PeoplesoftRel.ini", "FTP",
: "ACCT", FTPAcct
: IniFileGetKey "c:\progs\PeoplesoftRel.ini", "FTP",
: "USER", FTPUser
: IniFileGetKey "c:\progs\PeoplesoftRel.ini", "FTP",
: "PASSWORD", FTPPw
: IniFileGetKey "c:\progs\PeoplesoftRel.ini", "FILES",
: "TARGET", Target_Loc
: IniFileGetKey "c:\progs\PeoplesoftRel.ini", "FILES",
: "TARGETARCHIVE", TargetArch_Loc
: IniFileGetKey "c:\progs\PeoplesoftRel.ini", "FILES",
: "SOURCELOC", SLOC
: IniFileGetKey "c:\progs\PeoplesoftRel.ini", "FILES",
: "SOURCEFILE", SFile
: IniFileGetKey "c:\progs\PeoplesoftRel.ini", "FILES",
: "ARCHIVELOC", ArchiveLoc
: IniFileGetKey "c:\progs\PeoplesoftRel.ini", "FILES",
: "ERRORFILE", ErrorLog
: IniFileGetKey "c:\progs\PeoplesoftRel.ini", "FILES",
: "LOGFILE", LogFile
: IniFileGetKey "c:\progs\PeoplesoftRel.ini", "FILES",
: "NOTSENTLOC", NotSentLoc

: concat SLoc, SFile, Source_file

: // Start file search
: FileFindFirst( Source_file, FileName, found )
: LoopWhile( found, ENDLOOP )

: ConcatEx( SLoc, FileName, FoundFile )

: Concat( Target_Loc, FileName, TargetFile )

: Concat( TargetArch_Loc, FileName, TargetArch_File )

: FTPConfig( "Transfer Mode", "ASCII" )

: OnErrorGoTo FTP_ERR1

: //If file found in IN Log Error
: // FTPFileExists( FTPAcct, FTPUser, FTPPw, TargetFile, file_found )

: FTPFileExists( FTPAcct, FTPUser, FTPPw, FileName, file_found )

: if( file_found, LOG_FOUND_ERR, CHECK_BKP )

: CHECK_BKP: //If file found in BKP Log Error

: FTPFileExists( FTPAcct, FTPUser, FTPPw, TargetArch_File, file_found )

: if( file_found, LOG_FOUND_ERR, OK_TO_SEND )

: LOG_FOUND_ERR: // Get time

: Today( current_date )

: Now( current_time )

: DateTime( current_date, current_time, start_time )

: // Build text line

: Concatex( start_time, ": ", FileName, " - File Found in FTP
: Area. ", line )

: Concat( line, " File May have been sent before.", line )

: Concat( line, " Moving it to Hold Directory.", line )

: // Append to Error log file

: FileOpen( ErrorLog, "LineMode", "Write", TRUE,
: file_number )

: FileWrite( file_number, line )

: FileClose( file_number )

: // Moves file to the Not Sent Folder

: concat NotSentLoc, FileName, File2

: OnErrorGoTo FTP_ERR2

: FileMove( FoundFile, file2 )

: OnErrorResumeNext

: goto NEXT_FILE

: OK_TO_SEND: OnErrorGoTo FTP_ERR1

: FTPPutFile( FTPAcct, FTPUser, FTPPw, FoundFile, TargetFile )

: FTPFileExists( FTPAcct, FTPUser, FTPPw, TargetFile, file_found )

: OnErrorResumeNext

: //If file found Log OK file

: if( file_found, FILE_SENT_OK, FILE_ERR )

: FILE_ERR: // Get time

: .

: .

: OnErrorResumeNext

: goto NEXT_FILE

: FILE_SENT_OK: // Get time

: .

: .

: NEXT_FILE: // Find next file

: FileFindNext( FileName, found )
: ENDLOOP: exit

: FTP_ERR1: // Append to Error log file

: goto end_job

: FTP_ERR2: // Get time

: End_Job: exit

Thu Jun 16, 2005 2:54 pm View user's profile Send private message
Norm



Joined: 02 Sep 2004
Posts: 11

Post Re: Problem FTPFileExists Reply with quote

The Windows Internet Setting was correct.
The following are file names and indicator before
executing and after. The acct name, user name and
password are correct in that these same variables
work ok to transfer the file. I have also tried file
name of “TEST.TXT”.

Before
FILE_FOUND=""
TARGETFILE="/in/ROC06162005143927.DAT"

After
FILE_FOUND="true"
TARGETFILE="/in/ROC06162005143927.DAT"

FTPFileExists( FTPAcct, FTPUser, FTPPw, TargetFile, file_found )

Norm James
: First of all check if your Windows Internet settings don't have file caching
: enabled (click Control Panel, click Internet Options, in Temporary
: Internet Files box click Settings button, make sure "Every visit to
: the page..." option is checked. If not, checked, apply changes and
: restart 24x7.

: If that does not help, please provide an example of a full file name that you
: trying to check using FTPFileExists command.

Thu Jun 16, 2005 4:29 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7975

Post Re: Problem FTPFileExists Reply with quote

What do you get if you run then following script in place of FTPFileExists?

Dim( results, string )
FTPDir( FTPAcct, FTPUser, FTPPw, TargetFile, results )
MessageBox( results )

: The Windows Internet Setting was correct.
: The following are file names and indicator before
: executing and after. The acct name, user name and
: password are correct in that these same variables
: work ok to transfer the file. I have also tried file
: name of “TEST.TXT”.

: Before
: FILE_FOUND=""
: TARGETFILE="/in/ROC06162005143927.DAT"

: After
: FILE_FOUND="true"
: TARGETFILE="/in/ROC06162005143927.DAT"

: FTPFileExists( FTPAcct, FTPUser, FTPPw, TargetFile, file_found )

: Norm James

Thu Jun 16, 2005 4:44 pm View user's profile Send private message
Norm



Joined: 02 Sep 2004
Posts: 11

Post Re: Problem FTPFileExists Reply with quote

The statments below worked fine. I will use the FTPDir statment in my code at this point.
Thank you,
Norm James

: What do you get if you run then following script in place of FTPFileExists?

: Dim( results, string )
: FTPDir( FTPAcct, FTPUser, FTPPw, TargetFile, results )
: MessageBox( results )

Mon Jun 20, 2005 8:40 am View user's profile Send private message
Wilson



Joined: 21 Jun 2005
Posts: 1

Post Re: Problem FTPFileExists Reply with quote

I have run into the same problem. FTPFileExists is returning true even when the file does not exist. I made sure the Internet settings were correct, I have replaced FTPFileExists with the code you suggested and it's returning the following message:

WOWDATA.TXT not found

Why would FTPDir report correctly but FTPFileExists return a true value when the file doesn't actually exist?

: What do you get if you run then following script in place of FTPFileExists?
: Dim( results, string )
: FTPDir( FTPAcct, FTPUser, FTPPw, TargetFile, results )
: MessageBox( results )

Tue Jun 21, 2005 10:39 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7975

Post Re: Problem FTPFileExists Reply with quote

FTP protocol does not support structured or standardized output for "dir" type commands. So both FTPFileExists and FTPDir have to run external either "dir" or "ls" command depending on the host system type. Both FTPxxxx commands then attempt to parse the text output in order to extract file names, dates, sizes. The format of the output differs on different systems and this could cause the FTPFileExists to return incorrect results if it cannot understand the output or get something unexpected like extra lines.

In most cases
FTPDir ...., "file", list
NotEqual list, "", found

should lead to the same result
as FTPFileExists ..., "file", found

You can use whatever works better for you.

: I have run into the same problem. FTPFileExists is returning true even when
: the file does not exist. I made sure the Internet settings were correct, I
: have replaced FTPFileExists with the code you suggested and it's returning
: the following message: WOWDATA.TXT not found

: Why would FTPDir report correctly but FTPFileExists return a true value when
: the file doesn't actually exist?

Tue Jun 21, 2005 1:22 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.