cancel
Showing results for 
Search instead for 
Did you mean: 

Process file from agent server when the file is placed on the server

Former Member
0 Kudos

hi,

I have a requirement to process the file when it is placed on the agent server. If I schedule the task and use check file exists function or sleep function in Hci I can process the file. The requirement is if the file is not found after 30mins of wait time task should not be failed. Task should only fail when we have problem with processing file.

Regards

Sekhar

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Sekhar,

That's a nice challenge! I gave it a try and the below sample code worked fine for me. It will look for a file.txt and if not found within 30 seconds, it will raise an exception (and stop any further processing). If the file is found within 30 seconds it will start the actual dataflow. This script of course needs to be added as a pre-load script in your task. Note that $timer is defined in the task as a global variable of type integer.

$timer = 0;
while ( ( file_exists('c:/data/file.txt') = 0 ) and ( $timer <=30 ) )
begin
   sleep(1000);                   # wait 1000 miliseconds = 1 second
   $timer = $timer +1;            # add one second
end
If ($timer > 30)                  # check if timer exceeded 30 seconds
  raise_exception('No file found after 30 seconds');
else
  print('File found. Start processing...');
Former Member
0 Kudos

Hi Ben,

Thank you very much.

Regards

Sekhar

Former Member
0 Kudos

Hi Ben,

I have tried the pre-load script and the task is still failing if the file is not found.after the wait time. Will there be an option to set the task status as successful if the file is not found.

Regards

Sekhar