Automic Workload Automation

Expand all | Collapse all

Sending output of GET_PROCESS_LINE through email

Jump to Best Answer
  • 1.  Sending output of GET_PROCESS_LINE through email

    Posted 03-28-2019 04:41 AM

    Hello everyone!

     

    Customer requires to send a list of files in particular directory through email. If I am retrieving folder content using GET_PROCESS_LINE and save to variable, I am able to see FIRST LINE of that list only in the output email.

     

    Example:

     

    !create a list of /adc

     

    :SET &HND# = PREP_PROCESS("&ADC_HOST#","UNIXCMD",,"CMD=ls /adc","UC_LOGIN=&ADC_LOGIN#")
    :PROCESS &HND#
    : SET &OUTPUT# = GET_PROCESS_LINE(&HND#)
    : P &OUTPUT#
    :ENDPROCESS

     

    !send email with above lists

     

    :SET &FINAL_MAIL# = SEND_MAIL(&MAIL_ADDRESS#,,"List of ADC files","Hello, list of files: &OUTPUT#",,,)

     

    Following print command prints proper list in the script output:

     

    : P &OUTPUT#

     

    However, when sending an email using SEND_MAIL, only first line of &OUTPUT# is there

     

    Would you please suggest, how to print all the process lines in the outgoing email?

     

    Thank you in advance for your help!



  • 2.  Re: Sending output of GET_PROCESS_LINE through email

    Posted 03-28-2019 05:50 AM

    Hi,

     

    some time ago, i had the same problem to fix, and here is how i got around it:

     

    You can use the "PUT_ATT_APPEND CALL_TEXT" in a notification object to acomplish this. I built a
    monitor which monitors our events because of an old OS400 agent some events get stuck on get_filesystem :/ Anyways: Here is what i did: (in the script tab of the notification event)

     

    :PUT_ATT SUBJECT = "Alarm:'Problem bei EVENTs gefunden' Client:'&$client#'"
    : PUT_ATT_APPEND CALL_TEXT = 'Diese Events wurden neu gestartet, da die NEXT_CHECKTIME in der Vergangenheit liegt'
    : PUT_ATT_APPEND CALL_TEXT = UC_CRLF()
    : PUT_ATT_APPEND CALL_TEXT = UC_CRLF()
    :SET &HND#=PREP_PROCESS_VAR(VARA.SQLI#SYSMONITOR.OLD_EVENTS)
    :PROCESS &HND#
    :  SET &OBJEKT# = GET_PROCESS_LINE(&HND#,1)
    :  IF &OBJEKT# = ""
    :  ELSE
    :    PUT_ATT_APPEND CALL_TEXT = &OBJEKT#
    :    PUT_ATT_APPEND CALL_TEXT = UC_CRLF()
    :  ENDIF
    :ENDPROCESS

     

     

    Cheers

    Christoph



  • 3.  Re: Sending output of GET_PROCESS_LINE through email
    Best Answer

    Posted 03-28-2019 06:32 AM

    Hi,

     

    I think it's possible to do this

     

    :set &MAIL_ADDRESS# = "<EMAIL>"
    :set &nl# = UC_CRLF()
    :set &newline# = ""
    :SET &HND# = PREP_PROCESS("&ADC_HOST#","UNIXCMD",,"CMD=ls /adc","UC_LOGIN=&ADC_LOGIN#")
    :PROCESS &HND#
    :  SET &OUTPUT# = GET_PROCESS_LINE(&HND#)
    :  set &newline# = "&newline#&nl#&output#"

     

    :ENDPROCESS
    :close_process &HND#

     

    ! send email with above lists
    :SET &FINAL_MAIL# = SEND_MAIL(&MAIL_ADDRESS#, , "List of ADC files", "Hello, list of files: &newline#", , ,)

     

    Rgds

    Christian



  • 4.  Re: Sending output of GET_PROCESS_LINE through email

    Posted 03-28-2019 07:04 AM

    Gentlemen, thank you both for your quick help! Especially thanks to mr. kermitdiekralle, whose solution works as a charm!

     

    You made my day, thanks!