Redirecting output that was redirected to variable and console
Hi all,
I would like to store the output of a command in a variable and output it to the console at the same time. This is working fine using the following construct
I use this in some scripts to display the output of the command on the console and, at the same time check the output for certain flags, which indicate successful/failed execution (This may not be good practise and would better be done using the return code of the command, but I have no control over the command and some errors can only be detected by checking for certain output).
The problem is that the ouput of the above command can no longer be redirected. As an example:
will still output test.
Is there a better way to do this? Of course there are alternatives:
I could only store the output in the variable and not write it to the console simulteaniously. Once the command has completed the variable could be printed to the console. Though, I think it's nice to get a live view of what's going on.
Also, I'm aware that I could just tee the output to the console and a file and subsequently grep for the flags in the file. Though, I'd like to avoid creating a file.
So, is it possible to redirect the ouput of a command to the console and to a variable in a way, that you could also redirect the output that goes to the console at a later point in time?
When i am issuing chage command, it reporting the output properly.
But when i redirect the output, i am not getting the output in the mentioned path.
chage -l root >> /tmp/chage.txt.
I need to use this into the script to capture the data. I think its seems to be bug with RHEL 6.3. Same... (3 Replies)
Hi,
I need to install solaris remotely via the ILOM port on a x4170 box, and I have downloaded the Solaris 11 for x86 - text install image and burned it on a DVD.
When I boot the box, it's showing the boot_archive loading percentage on the SP console, but when it's done and start the interactive... (0 Replies)
Hi All,
Please could anyone advise what the purpose of the dot syntax in the following command means:
tar -cvf ${WORKING_BACKUP_ROOT}/${TAR_ARCHIVE_FILE} . >/${BACKUP_ROOT}/${ARCHIVE_LOG}
Many thanks (2 Replies)
Hi,
Pls check that '|' and '+' present in Step-1 are not copied to log file in Step-3.
Pls suggest how to get the exact output from Step-1 (i.e. with out losing '|' and '+') in to a log file
~Thanks
Step-1: Execute command
> mysql -utest -ptest -htesthost testdb -e "select * from... (3 Replies)
I want to execute a command something like:
find / -name "jni.h"
and I want to direct the output of that command to some type of
filter that will leave out all the lines reporting inaccessible
directories (permission unavailable). Is this a pipe or a redirect?
For example, output like... (1 Reply)
Hi. I'm a newbie in scripting and i have this problem: i want to use the 'fuser' command on a file to tell if it's being accessed (for my purposes: still being written). I want to save the output of the command and later compare with the 'not being used' result.
the script:
#!/bin/bash... (2 Replies)
I have to confirm that an engine was not able to run. In the output below you see that it indeed got errors, but it didn't send those messages to the output file. When I run the same thing with a different executable it works. So does this mean something in the executable could cause it not to... (7 Replies)
Hello Everyone,
I have an option for users in my shell script to create log file. So if user saying “yes” on it, I'm redirecting all output to log file by doing this: > /output.log. However I would like the output being displayed on the screen at the same time. Is it possible? If yes, does anybody... (2 Replies)
I have an application which has a lot of cout & cerr statements.
This application also opens a log file (for eg a.log).
When this application is run from the inittab file as follows
/bin/sh -c " . /etc/timezone; exec /test"
all the cout & cerr statements are printed in the log file... (1 Reply)