Why some commands do not work from stdin?

Discussion of the Co:Z Co-Processing Toolkit for z/OS
Post Reply
usaajrm
Posts: 80
Joined: Tue Feb 06, 2007 3:46 pm

Why some commands do not work from stdin?

Post by usaajrm » Fri Apr 01, 2011 12:00 pm

Why does the following command not work withing stdin?

printf "%s\n" "${BASH_VERSINFO[0]}"
stderr message:
-/bin/bash: line 5: ${BASH_VERSINFO[0]}: bad substitution

If i place the same command in an executable file on the linux box and then execute the file from stdin, the printf will work.

I'm also seeing a similiar behavior for array proccessing. My first approach was to place most of my bash processing in stdin. but now i've moved it down to the local script and invoke it from stdin.

dovetail
Site Admin
Posts: 1948
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail » Fri Apr 01, 2011 12:15 pm

COZBATCH runs your default z/OS Unix login shell.

Does this work from an interactive shell login?
Are you running bash?

usaajrm
Posts: 80
Joined: Tue Feb 06, 2007 3:46 pm

Post by usaajrm » Fri Apr 01, 2011 1:01 pm

yes, it runs from an interactive shell

and yes I'm running bash

It would eliminate an another script if I could use stdin. at least that was the thinking.

dovetail
Site Admin
Posts: 1948
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail » Fri Apr 01, 2011 1:20 pm

The only difference that I can imagine between running bash interactively on z/OS vs via COZBATCH is that, under COZBATCH, there isn't a "tty", but this really doesn't explain the problem that you are seeing.

So, in effect, what COZBATCH is doing is somthing like:

/bin/bash -l < dd:stding > dd:stdout 2>dd:stderr

Also, you might try inserting an "env" command at the beginning of your script. Is "LANG=C" set? I'm just wondering if there is something odd that prevents bracket characters from being recognized properly. Maybe you can double check (using "hex on") on ISPF what values you are using for brackets - perhaps it is a problem with your TN3270 emulator codepage? This would explain why brackets work in a Unix file if the bracket characters are a different code point there.

Post Reply