I have a TCSH script that calls a program. This program generates a file and outputs a message to the terminal window. Is there a way to store the message it outputs to a variable...so I can use it in my script?
In the called program you should be able to "return" with the msg variable as a parameter or in the called program print/echo the msg to stdout and call the program from your script like this:
msg=`program_name`
The program I am calling...I take its output and write it to a file, but the program writes if it was successful or not to the terminal window. I do not have access to manipulate the program...so I just want to capture its terminal window output to a variable.
Here's an example from my script (program is called and writes its output to test.txt):
program_name > test.txt
One example of the program's terminal window output that I want to store in a variable:
program successfully completed
So...is there a way to store this terminal window message to a variable?
Call the program redirecting stdout and stderr to output file and see if what is getting written to screen gets written to file:
program_name >test.txt &2>1