I would like to check for the existence of a directory and take action if it is not present. Following is a script extract:
[scriptftp="myscript.txt"]$srcdir="c:\user\output_files"
$result = LOCALCHDIR($srcdir)
IF $result != "OK"
$Files_to_process = 0
END IF[/ScriptFTP]
If the directory does not exist, The $result test returns a TRUE value, indicating there is an error. This is ok, because I want to know this. However, the logfile indicates that an error has occurred. I would like to suppress this in the log file, since I examine the file looking for errors. There are a large number of directories to process, and a missing directory is OK. I just don't want to process it.
Is there a way to do this? I have SILENT set to ON.
[scriptftp="myscript.txt"]$srcdir="c:\user\output_files"
$result = LOCALCHDIR($srcdir)
IF $result != "OK"
$Files_to_process = 0
END IF[/ScriptFTP]
If the directory does not exist, The $result test returns a TRUE value, indicating there is an error. This is ok, because I want to know this. However, the logfile indicates that an error has occurred. I would like to suppress this in the log file, since I examine the file looking for errors. There are a large number of directories to process, and a missing directory is OK. I just don't want to process it.
Is there a way to do this? I have SILENT set to ON.
Errors are always shown when SILENT is enabled. However you can check the existence of the directory in a different way:
[scriptftp="check_directory_exist.ftp"]# Change current local directory
LOCALCHDIR("C:\user\")
# Get the list of subdirectories
GETLIST($list_of_directories,LOCAL_DIRECTORIES)
$found="FALSE"
# Go subdirectory by subdirectory comparing if its name
# matches with the directory we want to find
FOREACH $directory_name IN $list_of_directories
# If the name matches set the variable to true
IF($directory_name=="output_files")
$found="TRUE"
END IF
END FOREACH
# if the variable still contains false means that the
# directory has not been found
IF($found=="FALSE")
PRINT("The directory has not been found")
$files_to_process=0
ELSE
PRINT("The directory has been found")
END IF[/ScriptFTP]
For those visiting this forum post and do not know what SILENT is:
http://www.scriptftp.com/reference.php?go=topic200
[scriptftp="check_directory_exist.ftp"]# Change current local directory
LOCALCHDIR("C:\user\")
# Get the list of subdirectories
GETLIST($list_of_directories,LOCAL_DIRECTORIES)
$found="FALSE"
# Go subdirectory by subdirectory comparing if its name
# matches with the directory we want to find
FOREACH $directory_name IN $list_of_directories
# If the name matches set the variable to true
IF($directory_name=="output_files")
$found="TRUE"
END IF
END FOREACH
# if the variable still contains false means that the
# directory has not been found
IF($found=="FALSE")
PRINT("The directory has not been found")
$files_to_process=0
ELSE
PRINT("The directory has been found")
END IF[/ScriptFTP]
For those visiting this forum post and do not know what SILENT is:
http://www.scriptftp.com/reference.php?go=topic200
liked Script FTP? Try our other product Email Parser
Yup. That'll do it. Thanks for the solution.