Automic Workload Automation

  • 1.  Best way to CHECK if file exists

    Posted Nov 12, 2014 01:27 PM
    Hi All,

    What is the best way to check if a file or files exists, then send a notification if there's no file(s)? 

    I am using AE9.
    JOBP(FTP)


  • 2.  Best way to CHECK if file exists
    Best Answer

    Posted Nov 12, 2014 02:07 PM
    Will you be checking the local file system or the remote file system?

    For checking the local file system, I typically will add an email step to the start of my workflow that has a precondition on it.  The precondition can check to see if the file exists or not.  I will also set up a static variable to hold a "HAVEFILE" or "NOFILE" setting.  The precondition rule will either set the variable to HAVEFILE and cause the email job to skip, or set the variable to NOFILE and cause the email job to execute, thus providing the automated notification.  Later steps in the same workflow can use precondition rules to query the static variable and decide if they should run or not.

    For checking the remote file system, I'll typically start out with an FTP step that just lists the contents of the target system, and add a post-process script to evaluate the report to decide if the desired file(s) exist or not.

    Pete


  • 3.  Best way to CHECK if file exists

    Posted Nov 12, 2014 02:11 PM
    There are many approaches and what is “best” for one may not be for another.  ;)

    Our normal approach for local files is to use the GET_FILESYSTEM Script function with the PATH_FILE_COUNT parameter in the Pre Process tab.  If the file does not exist we take the needed action.  Sometimes it is to use the STOP Script command with either the MSG or NOMSG parameter. There are often decisions to be made regarding the execution of successor tasks if the file is not available.

    If needed, an email will be sent as required usually using ACTIVATE_UC_OBJECT (we don’t use the SEND_MAIL function) in the Pre Process tab.



  • 4.  Best way to CHECK if file exists

    Posted Nov 19, 2014 08:36 AM
    Pete, I tried to start out with an FTP step and add a pre-process script to check if there a file or not, but I got an error message. Eventually, with the help of my co-worker, I was able to use the commands within the FTP and it worked. :-)

    Mark, that's absolutely true. After trial and error, I eventually figured what's best for me. ;-)


  • 5.  Best way to CHECK if file exists

    Posted Nov 25, 2014 01:19 PM
    This seems to work well.


    :set &RENAMED_FILE#="&inputpath#&renamedinputfile#"


    :SET &HND# = PREP_PROCESS_FILENAME("DEV-FIDBAT0001","&RENAMED_FILE#",,,,"UC_LOGIN=LOGIN.FID.BATCH")
    :PROCESS &HND#
    :set &FOUND#=GET_PROCESS_LINE(&HND#)
    :ENDPROCESS

    :if &FOUND#=&FLAG_FILE#
    :print FILE FOUND
    :else
    :print FILE NOT FOUND CARRY ON
    :endif


  • 6.  Best way to CHECK if file exists

    Posted Jan 20, 2015 02:24 PM
    I have a similar question in this vein...  We need to poll a remote site via an FTP agent to see if a file exists.  If so, then we want this FTP job to exit so we can proceed on to the next job to actually download it.  But if the file doesn't exist, then I want to do several retries at 5 minute intervals before throwing an error.

    Now if I'm polling for a static filename -- something like "abc123.txt", for example -- then the FTP job says "no such file" if the file doesn't exist.  I can easily search for that in my post-process tab and generate an error in these cases.

    But if the file I'm looking for is dynamic -- for example, "abc*123.txt" -- then I run into problems.  The FTP job doesn't report anything that I can grep for as confirmation of the file not being there.  I suppose I could count the number of rows of output in the report , but I'm not sure this would be a reliable way to tell in every case...


  • 7.  Best way to CHECK if file exists

    Posted Jan 21, 2015 01:07 PM
    I looked for an example, but I guess I don't have one.  I've always thought that one should be able to do the following; Build an FTP object that does nothing but lists the folder contents of the remote system. In a post-process script, scrape the report to determine if the desired file exists.   Script should set the contents of a UC4 static variable object accordingly. In the workflow task properties for the FTP object, build a post-condition rule that checks the contents of the UC4 static variable.  If it says the file doesn't exist yet, then tell the FTP object to restart in "n" minutes.


  • 8.  Best way to CHECK if file exists

    Posted Jul 31, 2017 01:56 PM
    I wrote a perl script a while back for AppWorx/Application Manager that performed remote file waiting.
    - passed in the location to check, the delay between checks, and a limit (how long to wait before regarding this as a failure).   As I recall this worked on both Windows and Linux (provided the correct perl componenets were available.   It predates this forum (I think).   If you still want it, let me know and I will dredge it up from my backups.  It would need to be updated for more recent versions and altered for the AE environment rather than AppWorx