Automic Workload Automation

PREP_PROCESS_VAR is being a little too "helpful"...

  • 1.  PREP_PROCESS_VAR is being a little too "helpful"...

    Posted 19 days ago
    Edited by Reed Byers 19 days ago
    Hi.  Me again, with another scripting issue that ought to have an easier answer.

    As a programmer, I want to be able to specify a file from our file system, and suck the entire contents of the file into a variable, for later manipulation (i.e. inclusion in an AWA notification email body).

    And lo!  There is a VARA.BACKEND!  I can pass it a script variable holding the filename, and it can CAT the file on our Linux system.  Then, we can do a PREP_PROCESS_VAR on it to loop through it and read it into a script var.

    So far, so good!

    EXCEPT, AWA is ever-so-helpfully skipping all of the blank lines in the file.  There are times when this would be very helpful.  This is not one of them.

    The backend variable part is working.  But the process loop finds no blank lines.

    The loop code is simple enough:

    ======================================
    :PSET &readfile# = "~/myfile.txt"
    :PSET &NL# = UC_CRLF()
    :PSET &EMAIL_TEXT# = ''
    :SET &x# = 0

    :SET &HND# = PREP_PROCESS_VAR(VARA.BACKEND.READFILE)
    :PROCESS &HND#
    :    SET &x# = &x# + 1
    :    SET &LINE#=GET_PROCESS_LINE(&HND#,2)
    :    PRINT "***** Line &x#) &line#"
    :    PSET &EMAIL_TEXT#=&EMAIL_TEXT#&LINE#&NL#
    :ENDPROCESS
    :CLOSE_PROCESS &HND#

    :PRINT &EMAIL_TEXT#
    ======================================

    Those line prints in the middle give the game away.  A blank line is never passed from the file.

    We REALLY don't want to have the backend var add a character to each line, and strip it off later in the loop -- but that's the solution we're looking at.

    Any other ideas?


    EDIT: Forgot to mention, we aren't using PREP_PROCESS_FILE because we don't want errors on a missing or empty file.  Our backend VARA cats the file and sends all errors to /dev/null.   Nice and tidy.  :)  Though it occurs to me that PREP_PROCESS_FILE wouldn't have had the same problems with blank lines...  :(


    ------------------------------
    Reed Byers
    Programmer/Analyst
    Oregon State University
    ------------------------------