command output to variable assignment and screen simultaneously
Hello Folks,
I have a script that runs a command (rsync) that sometimes takes a long time to complete and produces diagnostic output on stdout as it runs.
I am currently capturing this output in a variable and using it further in the script. I would like to continue to capture this output in a variable, but also display the output to the screen as it is produced from the command.
I am looking for a way to do this without creating a file on the filesystem. I am using Posix Shell on HP/UX and BASH on Linux (but open to other possibilities if necessary).
Currently I am doing this:
Any suggestions will be appreciated,
Man, talk about the forest hiding the trees! I tested this out, and it works great. I did have two hurdles. I'll explain them as others might have the same issues.
1) Wanted tty to be specified dynamically, and I tried originally with...
...but it wouldn't eval as the subshell wasn't attached to the tty. The obvious workaround was to set the tty to a variable first, then call it in the tee command:
2) Since piping to tee yields a return code of 0 even if the rsync command fails, I have another isssue. Since I'm using Posix Shell and not BASH in HPUX, I don't have access to $PIPESTATUS.
Instead, I gathered the idea to prefix the rsync command with a trap to let me know if it failed like so:
Later on in the code, I can echo "${output}" | grep 'RSYNC ERROR' and parse out the return code if necessary.
I have a section of a script where I want to check a log file for a certain oracle error and if there is only one error (and it is ORA-39152) then I want to email that script is complete. Otherwise email failure and log.
Somehow with this while the log only has one error and it is ORA-39152, I... (5 Replies)
Hi there,
I'm a newbie to Unix (taking a course in it right now) and I don't know how to do the following in bash:
I need to write a command to display information about the used and free space on the file system, showing only local file systems, and then send the output of the command to... (1 Reply)
Hi Folks,
I'm looking to figure something out in an existing script I'm trying to understand.
the command in question(on a Solaris Box using KSH) is: WORKDIR=/tmp/namereplaced.exec.$$.$RANDOM
Now, I know it's setting the $workdir environmental variable...
And I understand most of... (2 Replies)
Hi,
I'd like to redirect the STDOUT output from my script to a file and simultaneously display it at a console.
I've tried this command:
myscript.sh | tail -f
However, it doesn't end after the script finishes running
I've also tried this:
myscript.sh | tee ~/results.txt
But it writes... (3 Replies)
BACK STORY:
I have a script build.py . (It's for creating the ISO file for a special edition of Swift Linux.) This build.py script executes the mintConstructor.py script that I use to modify the Regular Swift Linux ISO to get the special edition Swift Linux ISO. The lines of the script that... (2 Replies)
Hi,
I want to use zenity --progress and also put the output to the terminal.
I tried using the tee command but that puts the output to the terminal first and then shows the zenity progress dialog.
Take the normal example by the gnome manual:
(
echo "10" ; sleep 1
... (0 Replies)
Hi Gurus,
I am having 2 parameters as below
parm1=value1
parm2=parm1
I want to evaluate parm1 value using eval echo \$$parm2 and later i want to assign this value to other variable which i will be using in if statement like :
if ]; then
do this.......
fi
could you please suggest... (5 Replies)
Hi folks,
Please advise which command/command line shall I run;
1) to display the command and its output on console
2) simultaneous to save the command and its output on a file
I tried tee command as follows;
$ ps aux | grep mysql | tee /path/to/output.txt
It displayed the... (7 Replies)
HI ,
I forgot to redirect my op to a file.The op which is quite huge , thus printed on the screen.However bcoz of the limited viewing in the screenI can not see the whole of the output..
Is there anyway I can see the full op.My run takes half a day for finnishing ..So I am refraining... (1 Reply)