On 06/04/2020 07:18, Istvan Gabor wrote:
Hello:
I have a program that can send its output to a script.
Now that's an ambiguous phrasing if ever I met one! As an old UNIX hacker the idea of a set of pipes&filters is natural enough ... find ... -print0 | xargs -0 ... | grep <parameters> | awk '{format ..}' comes naturally. But the kernel support for that as copocesses doesn't exist in MS-DOS or VMS even if the CLI permits that syntax. Is that what is meant by "can send its output"? Because as far as UNIX/Linux is concerned a script is just a program. There are many 'system' utilities that are implemented as perl or python scripts. All of YaST is implemented using Ruby scripts. Or perhaps the script itself makes use of other programs for file in $(find ... | grep <parameters> ) do ...
I can setup the script command in the program as: <script-name> option1 option2 ..., eg: myscript.sh name time.
I know that I can get the options in the script using $1 and $2 etc.
But how can I get the program's output that is sent to the script? I would like to write to output to a file.
I also would like to use the program's output to different purposes. Can I store it in a variable and use it later, or do I have to save it in a temporary file?
Possibly what you are looking for is program | tee savefile | script If you want a pipe that 'splits' then you need to set up the branch and there are ways to do that with the shell. q.v. man page But you can also cajole the above .. program | tee >(script1 > output.txt) >(script2 | grep ... | script3) Ain't the shell's ability to spawn coprocess and the syntax to pipeline wonderful? -- A: Yes. > Q: Are you sure? >> A: Because it reverses the logical flow of conversation. >>> Q: Why is top posting frowned upon? -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org