Wolfgang_Brueckler_1288

PREP_PROCESS ends up in a 'No such file or directory' error if the OS command returns RC > 0

Discussion created by Wolfgang_Brueckler_1288 on Feb 17, 2017
Latest reply on Feb 28, 2017 by Wolfgang_Brueckler_1288
Hi All

Does anyone of you use PREP_PROCESS with an linux OS command intensively?

 This week we observed, that - if the PREP_PROCESS OS command gets a Returncode > 0 the whole Script fails with status 1850 FAULT_OTHER and err message in MSG Window

16.02.2017 16:36:09 -  U00010038 Runtime error: Could not create data sequence 'FILETRANSFER'. Status: '0000001820', return code: '0000000000'.
16.02.2017 16:36:09 -  U00029003 Cannot open file '/home/apu001/EAQVOQXU.TXT(ReadFileAuthority())', error code '2', error description: 'No such file or directory'.
16.02.2017 16:36:09 -  U00011000 'REPORT' (RunID: '0199950004') could not be started on 'APU01C1'. See next message.
16.02.2017 16:36:09 -  U00011003 Job 'EVENT.UNIXCMD' (RunID '0199948028') on Host 'APU01C1' aborted (return code='0000000002'). Remote ID=13497

 
We just tried to find a workaround for the non- resolvement of soft links
https://community.automic.com/discussion/8806/prep-process-filename-does-not-resolve-soft-links-in-unix#latest
 

with using a short script:

: SET &CMD# = "ls &filename#"
: SET &HND# = PREP_PROCESS(&$AGENT#,"UNIXCMD","*","CMD = &CMD#","UC_LOGIN=&$LOGIN#")
: PROCESS &HND#
:   SET &LINE# = GET_PROCESS_LINE(&HND#)
:   PRINT &LINE#
: ENDPROCESS
: CLOSE_PROCESS &HND#

 

basically works, if &filename# exists on the OS

Nevertheless if the file is NOT existing, we got the error messages above  -which was not clear to us why.
 
After a while we found in EVENT.UNIXCMD (Client 0 -- Line 43-48) following code snippet:

 

##UC4[bash]&cmd > &home#&uc_eventfile 2>&1
##UC4[bash]UC_STATUS=$?
##UC4[bash]if  [ $UC_STATUS -gt 0 ]
##UC4[bash]then
##UC4[bash]    rm &home#&uc_eventfile
##UC4[bash]fi

means, if the Prep_Process Command returns RC >0 the Eventfile on the agent will be deleted.

??????

means furthermore, if the PREP_PROCESS OS command returns an error, the script which consists of the PREP_PROCESS will end in an FAULT_OTHER cause the Report File on the agent won't be found:

U00029003 Cannot open file '/home/apu001/EAQVOQXU.TXT(ReadFileAuthority())', error code '2', error description: 'No such file or directory'.

Thats complete misleading because the actual PREP_PROCESS OS command was executed successful but did not return a value or returned RC > 0

So one is supposing the AE Scripting caused an error but ther was just no result od the OS command

means furthermore that EVENT.UNIXCMD did not return any error to the calling object (the SCRi in our case))

This results in the fact that one never ever is able to react on any error messages caused by the OS command of PREP_PROCESS

would be great to check if a file exists - as we do or tried to do

I personally do not understand why the EVNT file (= Report File) is deleted when the OS command returns RC > 0
especially 4 lines above STD ERR is redirected to STDOUT using „2>&1“
???

we adjusted EVNT.UNIXCMD as shown below

##UC4[bash]if  [ $UC_STATUS -gt 0 ]
##UC4[bash]then
##UC4[bash]    cat /dev/null > &home#&uc_eventfile
##UC4[bash]fi

and the PREP_PROCESS command ran as expected:

if the file exists EVNT.UNIXCMD runs fine (ENDED_OK) and our script containing the PREP_PROCESS command runs fine too

if the file does NOT exist EVNT.UNIXCMD ends not OK (ENDED_NOT_OK - which ich correct in this case) and the script containing the PREP_PROCESS command runs fine too


Did anyone of you ran in this issue before?

I opened INC00129739  for an explanation through Development

have a nice weeken

Wolfgang

 


Outcomes