How to I capture Echo outcome into a variable in BASH script?

47 views Asked by At

We are trying to run a BASH script in IBMi system , one of our use case is to execute a CL program from Bash script that will copy sources from IFS to Library. We need a way to capture copy outcome and then perform some additional business logic in bash script.

Looking for options on how this can be coded -

  1. One of the option that we tried was to call CL program with a parameter, this did not work as bash script is not recognizing parameter value. In below script Result variable is being set inside CLPGM but it is not reflected when control comes back in bash script.
system "CALL PGM($lib/CLPGM) PARM('$Result')"
echo 
  1. Is there a way we can capture echo outcome after executing CL program into a variable ? We can set program message from CLPGM and it is getting echoed. Trying to see if there is a way to move echo outcome in a variable and then use that variable for adding evaluation in Bash script.
system "CALL PGM($lib/CLPGM) PARM('$Result')"
Outcome = $(echo)   ----------------> This did not work , command not recognised.

Thanks

New to using bash , looking for feedback on how this can be coded.

0

There are 0 answers