Skip to main content
Jun 14, 2017 12:54 PM UTC

Bash Shell & BPXBATCH

We have the 4.2.53 version of bash and are having problems with BPXBATCH when using the exec command.

bash -version
GNU bash, version 4.2.53(2)-release (i370-ibm-openedition)
Copyright © 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html

If the last line of my .profile contains an exec for the bash shell
When running a batch TMP with BPXBATCH it produces no output. (ie appears to run but just returns the READY prompt).

This is what I ran
//ADDIT EXEC PGM=IKJEFT01,REGION=0M,TIME=1440
//SYSTSPRT DD SYSOUT=*
//STDOUT DD SYSOUT=*
//STDERR DD SYSOUT=*
//SYSTSIN DD *
BPXBATCH SH ls -la
/*

Same results for PGM=BPXBATCH,PARM=(‘SH ls -la’)

This is what is in my .profile
exec /sysn/rs/bin/bash

    3 replies

    Jun 14, 2017 9:28 PM UTC

    We have the 4.2.53 version of bash and are having problems with BPXBATCH when using the exec command.

    bash -version
    GNU bash, version 4.2.53(2)-release (i370-ibm-openedition)
    Copyright © 2011 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html

    If the last line of my .profile contains an exec for the bash shell
    When running a batch TMP with BPXBATCH it produces no output. (ie appears to run but just returns the READY prompt).

    This is what I ran
    //ADDIT EXEC PGM=IKJEFT01,REGION=0M,TIME=1440
    //SYSTSPRT DD SYSOUT=*
    //STDOUT DD SYSOUT=*
    //STDERR DD SYSOUT=*
    //SYSTSIN DD *
    BPXBATCH SH ls -la
    /*

    Same results for PGM=BPXBATCH,PARM=(‘SH ls -la’)

    This is what is in my .profile
    exec /sysn/rs/bin/bash

    My guess is that you get no output because STDOUT and STDERR are not Unix kernal fds, and so they do not survive the exec. If instead you use PATH=/tmp/my_stderr, along with the two other keywords, to send the output to a USS file, and then add a second step to copy the results to the spool, it should work. You may need to second step to use BPXBATSL with PGM /bin/cp to ensure that the sysout DDs are available when they are needed. Or you can do it in one step (at least in this case), by using PGM /bin/ls along with BPXBATSL.

    Jun 15, 2017 11:59 AM UTC

    My guess is that you get no output because STDOUT and STDERR are not Unix kernal fds, and so they do not survive the exec. If instead you use PATH=/tmp/my_stderr, along with the two other keywords, to send the output to a USS file, and then add a second step to copy the results to the spool, it should work. You may need to second step to use BPXBATSL with PGM /bin/cp to ensure that the sysout DDs are available when they are needed. Or you can do it in one step (at least in this case), by using PGM /bin/ls along with BPXBATSL.

    I think it’s the fact that I am using exec in my profile if I change that to /sysn/rs/bin/bash (ie remove the exec it works)
    I am using the exec so it don’t have to exit twice.

    Jun 19, 2017 2:54 AM UTC

    We have the 4.2.53 version of bash and are having problems with BPXBATCH when using the exec command.

    bash -version
    GNU bash, version 4.2.53(2)-release (i370-ibm-openedition)
    Copyright © 2011 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html

    If the last line of my .profile contains an exec for the bash shell
    When running a batch TMP with BPXBATCH it produces no output. (ie appears to run but just returns the READY prompt).

    This is what I ran
    //ADDIT EXEC PGM=IKJEFT01,REGION=0M,TIME=1440
    //SYSTSPRT DD SYSOUT=*
    //STDOUT DD SYSOUT=*
    //STDERR DD SYSOUT=*
    //SYSTSIN DD *
    BPXBATCH SH ls -la
    /*

    Same results for PGM=BPXBATCH,PARM=(‘SH ls -la’)

    This is what is in my .profile
    exec /sysn/rs/bin/bash

    Recommendation:

    In your ~/.profile do:

     exec /sysn/rs/bin/bash -l