New dataset pipe utility idea.

Discussion of the Co:Z Toolkit Dataset Pipes utilities
Post Reply
john.mckown
Posts: 48
Joined: Tue Jun 12, 2007 2:46 pm

New dataset pipe utility idea.

Post by john.mckown »

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.
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

John,

Its not clear to me what the arguments to --stdin= etc are intended to be. Can you please give an example?

I guess if you wanted them to go to the same dataset you could use:

fromdsn //input || uniix-command --switches 2>&1 | todsn //output

Kirk
john.mckown
Posts: 48
Joined: Tue Jun 12, 2007 2:46 pm

Post by john.mckown »

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.
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

You might also try creating a fifo with mkfifo and then redirect stderr to the fifo and then fork a todsn command to read from that fifo and write to a dataset.
john.mckown
Posts: 48
Joined: Tue Jun 12, 2007 2:46 pm

Post by john.mckown »

Good idea about the FIFO. A bit more difficult from the end-user side, but possible.
Post Reply