Skip to Content
0

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

Mar 29, 2017 at 02:47 PM

91

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Ben Hofmans
Mar 30, 2017 at 12:29 PM
0

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...');
Show 2 Share
10 |10000 characters needed characters left characters exceeded

Hi Ben,

Thank you very much.

Regards

Sekhar

0

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

0