Skip to Content
avatar image
Former Member

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

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Mar 30, 2017 at 12:29 PM

    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...');
    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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