Why some commands do not work from stdin?

General discussion of the Co:Z Toolkit
Post Reply
usaajrm
Posts: 87
Joined: Tue Feb 06, 2007 3:46 pm

Why some commands do not work from stdin?

Post by usaajrm »

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: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

COZBATCH runs your default z/OS Unix login shell.

Does this work from an interactive shell login?
Are you running bash?
usaajrm
Posts: 87
Joined: Tue Feb 06, 2007 3:46 pm

Post by usaajrm »

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: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

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