Automic Workload Automation

 View Only
  • 1.  Workflow Question - assess file size

    Posted Jan 14, 2014 02:54 PM

    Hi I am a newbie to Automic.  Here is my question:

      I have a Workflow that kicks off a process in PeopleSoft to generate an output file.  That file may contain rows of data I want to pass to my target system or the file may only contain the column headers and I would like to not pass that file; just archive it in the PeopleSoft folder (later task in workflow).  Is there a way to modify my event object to assess the scenario (file size) to determine what task to execute next?  Right now the event is looking for a file size greater than 128 bytes.  If the file is less than 128 bytes the workflow currently ends. 

     

    File with rows to pass: execute all workflow tasks (transfer to UC4, transfer to target system, archive file in PS)

    File with no rows to pass:  at the event task if the file is less than 128 bytes move to the archive file in PS task (6) – skipping all the transfer tasks

    Thanks for any insight!

    Lynn



  • 2.  Workflow Question - assess file size

    Posted Jan 15, 2014 03:49 AM

    Hi Lynn,

    I only know a solution that uses a scripting language but am very interested if a regular solution is available. 

    Presuming the previous process is finished and the file is stable you can read the size of a file with a script. Depending on the operating system this could be a Command prompt or PowerShell and capture the output post-process. I currently have a Windows job that  echos the size of a variable file by the command below. Post-process I scan the report and promote the variable with PSET so I can use it in further steps. In your case this could be an IF workflow with a USER DEFINED condition checking the variable. 

    Process:

    echo off
    echo [START_MARKER]

    forfiles /p &PATH# /m &FILENAME# /c "cmd /c echo @fsize"
    echo [END_MARKER]

    Post-Process:

    ! Define variable to determine whether report content has started
    :DEFINE &ISCONTENT#, unsigned
    :SET &ISCONTENT# = 0
    ! Retrieve process report and loop through
    :SET &HANDLE# = PREP_PROCESS_REPORT(,,REP, '')
    :PROCESS &HANDLE#
    :    SET &LINE# = GET_PROCESS_LINE(&HANDLE#) 
    ! Determine end marker
    :    IF &LINE# = '[END_MARKER]' 
    :        SET &ISCONTENT# = 0 
    :    ENDIF 
    ! If content, then process, only allows one line and overwrites when multiple lines are found
    :    IF &ISCONTENT# = 1 
    :        IF &LINE# <> '' 
    :            SET &VALUE# = &LINE# 
    :            PSET &FILE_SIZE# = CONVERT(unsigned, &VALUE#) 
    :        ENDIF 
    :    ENDIF 
    ! Determine start marker at the end, to exclude marker itself
    :    IF &LINE# = '[START_MARKER]' 
    :        SET &ISCONTENT# = 1 
    :    ENDIF 
    :ENDPROCESS
    :CLOSE_PROCESS &HANDLE#

    I also use an output scan to filter incorrect paths and filenames so the workflow will fail when a file could not be found.

    I hope this helps! Good luck,

    Jeroen



  • 3.  Workflow Question - assess file size

    Posted Jan 15, 2014 01:09 PM

    Lynn:

    I would probably approach this by “encapsulating” the tasks that are not to execute if the file is less than 128 bytes into a sub-process flow.  Have the Event object END_OK if the file is greater than 128 bytes and NOT_OK if it is less than that value.  Have the sub-process flow as a successor to the Event and its Dependency match a Status of NOT_OK, else Skip.  Then, the remaining tasks follow the sub-process flow and check for a Status of ANY_OK.

    Something like:

              Event ===> Sub-process ===> Remaining tasks

    I probably would not use an Event but a Script with the GET_FILESYSTEM function to make the check unless the Event is also needed to wait for the file's arrival. 

    You could also use the GET_FILESYSTEM function in the Process tab of the sub-process flow to check the file's size and if too small use the STOP NOMSG function to end execution of the flow.  This way you avoid having to deal with ending the Event differently depending on the file size.

    Hope this helps.

    Mark



  • 4.  Workflow Question - assess file size

    Posted Jul 17, 2017 09:58 PM
    hi LynnSlaga605066
     I bring this topic up as we have the same request with Support.
    I found another post which seem to fulfill your request: https://community.automic.com/discussion/634/automic-v9-how-to-get-file-size

    If you access the link, you will find there is an example of using GET_FILESYSTEM to get the file size.
    For example, you can copy below code to your job's Process tab:

    :SET &agent = "win01" ! Windows Agent name where the file exists
    :SET &file = "C:\Test\test.txt" ! exact file path and name
    :SET &size = GET_FILESYSTEM(&agent,&file,PATH_SPACE_USED,BYTES) ! Use MB in case of Megabytes
    :PRINT "Size of &file:  &size Bytes"
    ! Additional logic to communicate result such as
    ! STOP NOMSG if subsequent tasks are not to be executed.
    :IF &size > 100000000 ! 100MB
    :   EXIT
    :ENDIF

    This script will end the Job with End_not_Ok if the file bigger than 10MB.
    Add this job to your workflow, consider @Mark answer above.

    I hope this helps!


  • 5.  RE: Workflow Question - assess file size

    Posted May 18, 2022 12:26 PM
    For me it didn t work.

    It shows 0000000000000000 Bytes even if the file has more than 0 bytes, I tried with many files the same. Should be the issue it the shared folder path 
    Size of \\server1\folder1\file.txt:  0000000000000000 Bytes