Edgars_Voroboks_1909

How to set variable value from unix command's return

Discussion created by Edgars_Voroboks_1909 on Jan 8, 2015
Latest reply on Sep 29, 2015 by eric.felker
I want to send e-mail notifications when there are files found in remote server's directory. Agent is installed on remote server.
JOBS gets &DIR# as variable "/path/to/directory"
JOBS Process tab:
cd &DIR# ls -1 | wc -l
JOBS Post Process tab:
:SET &hnd# = PREP_PROCESS_REPORT(,,REP,) :PROCESS &hnd# :  SET &line# = GET_PROCESS_LINE(&hnd#) :  IF STR_FIND(&line#,"*") > 0 :    IF &line# = 0 :      SET &OUT# = SEND_MAIL('me@example.com',,'Found &line# files','Found &line# files in &DIR#!',) :    ENDIF :  ENDIF :ENDPROCESS
This is shown in Report after JOBS execution:
************************************************************************ **  ucxjlx6m   version 10.0.2+build.624         changelist 5277596    ** **  JOB 01043032 (ProcID:0000014241) START AT 08.01.2015 / 15:31:04   ** **                                   UTC TIME 08.01.2015 / 13:31:04   ** **  TEXT="        Job started             "                           ** ************************************************************************ 23 ************************************************************************ **  ucxjlx6m   version 10.0.2+build.624         changelist 5277596    ** **  JOB 01043032 (ProcID:0000014241) ENDED AT 08.01.2015 / 15:31:04   ** **                                   UTC TIME 08.01.2015 / 13:31:04   ** **  TEXT="        Job ended               "  RETCODE=00               ** ************************************************************************
And I receive an email.

TL;DR:
Is there any easy way to get response from unix script as variable?
Like
&COUNT# = "ls -1 | wc -l"
, but not as text, but command's response.

Outcomes