Page 1 of 1

FTP File Exists

Posted: Tue Sep 11, 2018 2:49 pm
by fordj36
Sorry this may have been asked before, but I can't find it. I need to check a remote ftp service for a particular file.
When I use the "FTP File Loop" task if I put the file name in the "Remote Folder and File Mask" box it doesn't find the file.
But if I put *.msg in the box it finds the file.

Re: FTP File Exists

Posted: Fri Oct 26, 2018 11:04 pm
by esantos
I have the same doubt.

Re: FTP File Exists

Posted: Wed Oct 31, 2018 9:39 am
by Oleg
Will be in next release in sFTP and SSL FTP actions

Now you can check the existence of the file by standard algorithm in the loop.
Look at my example:

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|799993286
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task544"
Hide=INTEGER|0
ID=INTEGER|-1079361276
LogOnAsUser=INTEGER|1
Name=STRING|"FTP check file existence"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action10=FOLDER
Action11=FOLDER
Action12=FOLDER
Action13=FOLDER
Action14=FOLDER
Action15=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""TESTFILENAME"" with value ""test.txt"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varname=STRING|"TESTFILENAME"
varvalue=STRING|"test.txt"

[Actions\Action10]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"

[Actions\Action11]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER

[Actions\Action11\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"0"
type=STRING|"3"
value1=STRING|"{Exist}"

[Actions\Action12]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""File ""{TestFileName}"" exists"""
Params=FOLDER

[Actions\Action12\Params]
icon=STRING|"1"
msg0=STRING|"File ""{TestFileName}"" exists"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action13]
ActionID=STRING|"A_FLOW_ELSE"
Enabled=INTEGER|-1
Name=STRING|"Else"

[Actions\Action14]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""File ""{TestFileName}"" doesn't exist"""
Params=FOLDER

[Actions\Action14\Params]
icon=STRING|"3"
msg0=STRING|"File ""{TestFileName}"" doesn't exist"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action15]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"

[Actions\Action2]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""EXIST"" with value ""FALSE"""
Params=FOLDER

[Actions\Action2\Params]
expand=STRING|"0"
varname=STRING|"EXIST"
varvalue=STRING|"FALSE"

[Actions\Action3]
ActionID=STRING|"A_SSLFTP_LOGON"
Enabled=INTEGER|-1
Name=STRING|"SSL FTP Log On"
Params=FOLDER

[Actions\Action3\Params]
anonymous=STRING|"1"
host=STRING|"ftp.company.com"
passive=STRING|"1"
password=STRING|"42310383162884337286400984055142142"
port=STRING|"21"
proxypassword=STRING|"2591325970249442622624944"
proxytype=STRING|"3"
tlsmode=STRING|"0"
useproxy=STRING|"0"
username=STRING|"anonymous"
usessl2=STRING|"0"
usessl3=STRING|"0"
usestls=STRING|"1"
usestls11=STRING|"1"
usestls12=STRING|"1"

[Actions\Action4]
ActionID=STRING|"A_SSLFTP_CHANGEFOLDER"
Enabled=INTEGER|-1
Name=STRING|"SSL FTP Change Folder"
Params=FOLDER

[Actions\Action4\Params]
folder=STRING|"testfolder"

[Actions\Action5]
ActionID=STRING|"A_SSLFTP_FILELOOP"
Enabled=INTEGER|-1
Name=STRING|"SSL FTP File Loop"
Params=FOLDER

[Actions\Action5\Params]
createmode=STRING|"1"
date1=STRING|"18991230"
date2=STRING|"18991230"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
filenameonly=STRING|"0"
folder=STRING|"{TestFileName}*"
kind=STRING|"0"
OlderDays=STRING|"1"
OlderHours=STRING|"1"
OlderMinutes=STRING|"1"
OlderMonths=STRING|"1"
sizesave=STRING|"0"
sort=STRING|"0"
sortby=STRING|"0"
sortorder=STRING|"0"
subfolders=STRING|"0"
timesave=STRING|"0"
varname=STRING|"FTPFILE"

[Actions\Action6]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER

[Actions\Action6\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"0"
type=STRING|"0"
value1=STRING|"{TestFileName}"
value2=STRING|"{ftpfile}"

[Actions\Action7]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""EXIST"" with value ""TRUE"""
Params=FOLDER

[Actions\Action7\Params]
expand=STRING|"0"
varname=STRING|"EXIST"
varvalue=STRING|"TRUE"

[Actions\Action8]
ActionID=STRING|"A_LOOP_BREAK"
Enabled=INTEGER|-1
Name=STRING|"Break"

[Actions\Action9]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"
You can use SSL FTP actions for plain FTP protocol too.

Re: FTP File Exists

Posted: Wed Oct 31, 2018 11:42 pm
by esantos
Hello oleg, thanks for the script, it will be useful to me.
When I use sFTP, I use the ls command to list the contents of the folder and play this content to a variable, so I do an if to confirm if the file I want is in sFTP. Could you add the variable option also for FTP and SSL FTP?