When I want input and output from a UNIX command which does not support reading and writing MVS datasets, I can pipe together the "fromdsn" and "todsn" commands with my command "sandwiched" between them. Something like:
fromdsn "//'my.input'" | unix-command --switches | todsn "//'my.output'"
This works really nice EXCEPT if if want to direct STDERR to a z/OS dataset as well. So, being the idiot that I am, I thought it might be nice to have a command similar to:
redirect --stdin=... --stdout=... --stderr=... -- unix-command --switches
The any of the --stdin, --stdout, and/or --stderr are optional. The double dash simply says that the remainder of the arguments are the unix command followed by its switches.
The redirect command would set up the stdin, stdout, and/or stderr as needed as pipes, then fork() and exec() the unix-command. I am thinking this is necessary because to read / write from / to the z/OS files, the redirect command would need to actually do the z/OS reading/writing. I.e. it would read from the z/OS "stdin" file and send the data out via a pipe which was set up as the stdin for "unix-command". Likewise, for stdout and stderr, it would read the associated pipe and write to the associated dataset.
Am I making any sense? Or is this a silly idea? I may write something like this in REXX. I don't have a C compiler at work.
Another thing this would do is set up so that "unix-command" would read from the STDIN which is associated with the "redirect" command, if not reassigned. Likewise, it would write to the STDOUT and STDERR associated with the "redirect" command if not reassigned via the --stdout= or --stderr parameter.
New dataset pipe utility idea.
-
- Posts: 48
- Joined: Tue Jun 12, 2007 2:46 pm
I was thinking someting like:
redirect --stdin="//INPUT" --stdout="//STDOUT" \
--stderr="//STDERR" -- complex_command -switch1 -switch2
The "complex_command" would get its input from INPUT. Its stdout would go to STDOUT. Its stderr would go to STDERR. I can almost accomplish this via:
fromdsn "//INPUT" | complex_command -switch1 -switch 2 |\
todsn "//STDOUT"
But there is no way to get the stderr into dataset STDERR.
Just a silly idea.
redirect --stdin="//INPUT" --stdout="//STDOUT" \
--stderr="//STDERR" -- complex_command -switch1 -switch2
The "complex_command" would get its input from INPUT. Its stdout would go to STDOUT. Its stderr would go to STDERR. I can almost accomplish this via:
fromdsn "//INPUT" | complex_command -switch1 -switch 2 |\
todsn "//STDOUT"
But there is no way to get the stderr into dataset STDERR.
Just a silly idea.
-
- Posts: 48
- Joined: Tue Jun 12, 2007 2:46 pm