I am trying to pipe a dataset to sed with the following syntax but the output file is empty. Is this the right syntax to pipe into sed?
fromdsn -b DD:INPUT \
sed 's/fromstring/tostring/g' \
todsn -b DD:OUTPUT
If I need to have multiple sed statements how can I do that?
Dataset pipes with sed edit
Re: Dataset pipes with sed edit
You're pretty close - you just need to stand your pipes up a little straighter
Try this instead:
Try this instead:
Code: Select all
fromdsn -b DD:INPUT |
sed 's/fromstring/tostring/g' |
todsn -b DD:OUTPUT
Re: Dataset pipes with sed edit
Can't get any straighter than that, but it still does not work. The edited data is not written to the output, just the original data.
sed needs to be told to send the edited data to the output file with > , something like in the the following statements, but it does not work, maybe the syntax again?.
And how can I have multiple sed commands.
fromdsn -b DD:INPUT |
sed 's/fromstring/tostring/g' > |
todsn -b DD:OUTPUT
sed needs to be told to send the edited data to the output file with > , something like in the the following statements, but it does not work, maybe the syntax again?.
And how can I have multiple sed commands.
fromdsn -b DD:INPUT |
sed 's/fromstring/tostring/g' > |
todsn -b DD:OUTPUT
Re: Dataset pipes with sed edit
sed writes to stdout, which feeds the write end of the pipe in my example. You don't need any redirection.
I can't see what your DDs refer to, but you may not want to be using the -b switch. This tells fromdsn and todsn to process the data without any line separators, which may not be what you want. If you really intend to use -b, check to make sure that your DCBs are compatible.
Check out the -e and -f options for sed to issue multiple commands, or as an alternative look into using awk.
I can't see what your DDs refer to, but you may not want to be using the -b switch. This tells fromdsn and todsn to process the data without any line separators, which may not be what you want. If you really intend to use -b, check to make sure that your DCBs are compatible.
Check out the -e and -f options for sed to issue multiple commands, or as an alternative look into using awk.
Re: Dataset pipes with sed edit
I have a z/os dataset SEDEDIT with multiple sed statements such as "sed -e -i .....| sed -e -i | sed -e -i" and a linux file tobedited.txt. I need to edit the tbeedited.file using the SEDEDIT and send the output to a dataset. I tried many syntax variations but I keep getting a message similar to /bin/bash DD:SEDFILE not found. What is the correct syntax?
tobeedited.file | //DD:SEDFILE todsn -b //DD:EDITED
tobeedited.file | //DD:SEDFILE todsn -b //DD:EDITED
Re: Dataset pipes with sed edit
So, if I understand, what you want is a command like this:
(where the middle line comes from the DD:SEDFILE)
One way would be to use DD concatenation (if SEDFILE ended in a | )
Code: Select all
cat tobeedited.file |
sed -e -i .....| sed -e -i | sed -e -i |
todsn -b //DD:EDITED
One way would be to use DD concatenation (if SEDFILE ended in a | )
Another way would be to use bash process substitution combined with "source" -//STDIN DD *
cat tobeeditted.file |
// DD DDNAME=SEDFILE
// DD *
todsn -b //DD:EDITED
//
BTW - Are you sure that you want "-b" on the todsn command?//STDIN DD*
cat tobeedited.file |
source <(fromdsn DD:SEDFILE) |
todsn -b //DD EDITED
//
Re: Dataset pipes with sed edit
I get the following error with this command:
cat SYSPRI2 | source <(fromdsn //DD:SEDFILE) | todsn -b //DD:OUT
todsn-client(11533)?E?: todsn(DD:OUT): error: no input data available, rc=103,
todsn-client(11533)?E?: server exit_code=103
cat SYSPRI2 | source <(fromdsn //DD:SEDFILE) | todsn -b //DD:OUT
todsn-client(11533)?E?: todsn(DD:OUT): error: no input data available, rc=103,
todsn-client(11533)?E?: server exit_code=103
Re: Dataset pipes with sed edit
that means that todsn didn't find any input data on stdin. The -z switch will eliminate this warning, but that probably isn't what you want.
Re: Dataset pipes with sed edit
The file SYSPRI2 does have data, so why is it giving this error.
Re: Dataset pipes with sed edit
apparently there isn't any output from the last pipeline.
Try taking off the "| todsn ..." and let the output go to stdout.
Maybe try putting the sed commands in the script directly first and debugging them there.
Try taking off the "| todsn ..." and let the output go to stdout.
Maybe try putting the sed commands in the script directly first and debugging them there.