I am using the current script below that runs every 30 minutes. I am looking to find a way to modify the log file to only save if it actually downloads files. I want to be able to save only files that have relavant data and currently have to go through each file to see what ones to keep.. Any suggestions?
Code: Select all
#FPMSI - Download POD Orders to Creo
# Connect to ftp.myhost.com as myuser
$result=OPENHOST("address","username","pw")
# If OPENHOST failed stop the script
IF($result!="OK")
STOP
END IF
# Change the current local directory. The files
# will be downloaded here.
$result=LOCALCHDIR("C:\VirtusPod")
# If LOCALCHDIR failed stop the script
IF($result!="OK")
STOP
END IF
# Change current remote directory to
CHDIR("out")
$date=GETDATE
$logfile="C:\VirtusPod\POD_Download_log-".$date.".txt"
#Log Downloads
LOGTO($logfile,append)
#("C:\VirtusPod\PODdownloadlog.log",append)
# Get the remote file listing, store it in $list
$result=GETLIST($list,REMOTE_FILES,"*.*")
# If GETLIST failed stop the script
IF($result!="OK")
STOP
END IF
# For each file in $list...
FOREACH $item IN $list
# Download the file
$result=GETFILE($item)
# If the file has been succesfully downloaded
  # delete the remote copy. If not stop the script.
IF($result=="OK")
DELETEFILE($item)
ELSE
STOP
END IF
END FOREACH
STOPLOG()
#EXEC("Copy C:\VirtusPod\*.pdf D:\HotFolders\HF_VirtusC2")
EXEC("cmd.exe /c C:\VirtusPod\virtus.bat")
# Close the connection
CLOSEHOST
Â
****** Updated. This answer is not related to what Fpmsi means. See the next post from ScriptFTP support.
Have you tried to enable the SILENT mode? Put it this on the top of your script file:
http://www.scriptftp.com/reference.php?go=topic200
But feel free to post again if you have any question.
Have you tried to enable the SILENT mode? Put it this on the top of your script file:
Code: Select all
Further info here:#Show only transferred files, errors and PRINT command messages:
SILENT(ON)
http://www.scriptftp.com/reference.php?go=topic200
But feel free to post again if you have any question.
liked Script FTP? Try our other product Email Parser
Thanks but that didnt seem to do what I am looking for.
The script about is using the following code to create a log file.. I want to save this log file with the file names and etc that it downloaded durint the run.
in the text document and saves the file.. So i have to go through all txt files to see what files have logs of downloads. So basically if Found files is 0 I dont want it to create a log..
Any ideas or if this is possible..
Thanks for the help...
The script about is using the following code to create a log file.. I want to save this log file with the file names and etc that it downloaded durint the run.
Code: Select all
But if the script does not download anything it just imputs $date=GETDATE
$logfile="C:\VirtusPod\POD_Download_log-".$date.".txt"
#Log Downloads
LOGTO($logfile,append)
GETLIST(REMOTE_FILES,"*.*")
Getting file listing of current remote directory
Found 0 files.
STOPLOG()
Stoping output logging
in the text document and saves the file.. So i have to go through all txt files to see what files have logs of downloads. So basically if Found files is 0 I dont want it to create a log..
Any ideas or if this is possible..
Thanks for the help...
Ok, now I understand your case. I suggest you to check first if there are files at the server before calling LOGTO. For example:
Code: Select all
Note that the command COUNTELEMENTS is not documented, my fault, sorry.# Get the remote file listing, store it in $list
$result=GETLIST($list,REMOTE_FILES,"*.*")
# If GETLIST failed stop the script
IF($result!="OK")
STOP
END IF
# Count the number of elements of the list
# If it is 0 we disconnect from the server and stop the script,
IF(COUNTELEMENTS($list))==0)
CLOSEHOST
STOP
END IF
# Start logging from now on
LOGTO("mylog.txt")
# Files found. Do the stuff here
liked Script FTP? Try our other product Email Parser