redirecting std error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting redirecting std error
# 1  
Old 08-15-2008
redirecting std error

Hi,
I use the following command

make all > output-`date +%F-%H-%M-%S`.txt 2>&1

to invoke a MAKE process that takes some weeks to complete. The ouput is redirected to a text file. Now I prefix the above command with time to get time needed for completion of the MAKE process

time make all > output-`date +%F-%H-%M-%S`.txt 2>&1

I would like the output of time to be written in the same file as the output of MAKE instead of the std error.
I have tried a couple of combinations without success.
Please help
Thanks GA
# 2  
Old 08-15-2008
Code:
mydate=`date +%F-%H-%M-%S` && echo $mydate > output-$mydate.txt && time make all &>> output-$mydate.txt

# 3  
Old 08-15-2008
Use parens to capture output from time to file

>cat a.sh
echo Hello, this is a.sh running
echo Here is a.sh writing to stderr >&2

>a.sh
Hello, this is a.sh running
Here is a.sh writing to stderr

>a.sh 2>err
Hello, this is a.sh running

>a.sh >out
Here is a.sh writing to stderr

>(time a.sh) 2>err
Hello, this is a.sh running

>cat err
Here is a.sh writing to stderr

real 0m0.021s
user 0m0.000s
sys 0m0.000s
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Awk: Print Error While Redirecting output in multiple Files

Hi, I have a following code in which I am unable to redirect to multiple files. Can anybody please help with some corrections awk -F, '{ if ( substr($1,26,2)=="02" && substr($1,184,14)=="MTSCC_VALFIRST") { array1++ array2++ array3++ } else if (substr($1,26,2)=="03" &&... (4 Replies)
Discussion started by: siramitsharma
4 Replies

2. Programming

C++ compilation error when I use predicate friend function in the std::sort()

Hi, Can anyone tell me why the following program is giving compiler error when I use a friend function of a class as the comparison predicate for the third parameter of std::sort() algorithm? How to correct it, keep the 'friend' intact? #include <iostream> #include <vector> #include <list>... (1 Reply)
Discussion started by: royalibrahim
1 Replies

3. Shell Programming and Scripting

Regarding Redirecting a command's default error message in script

Hi, I just need a small help. I have this simple script to check a huge list of IDs if they exist or not on a server. Before running I have tested it with only 5-6 IDs. Script works fine. But what I need it should not display the message of command's error message. That means if suppose an ID... (3 Replies)
Discussion started by: raj100
3 Replies

4. Shell Programming and Scripting

Redirecting standard error issues.

Hello Friends, Good Day. I am trying to redirect a standard error to the bit bucket(/dev/null) but it is not working. Though, it is working fine in redirecting the standard output. Below is the output of my script without any redirection: $ ./CheckVSSLocks.sh... (16 Replies)
Discussion started by: singh.chandan18
16 Replies

5. Shell Programming and Scripting

Is there a way to tee stderr from a command that's redirecting error to a file?

I'm not a complete novice at unix but I'm not all that advanced either. I'm hoping that someone with a little more knowledge than myself has the answer I'm looking for. I'm writing a wrapper script that will be passed user commands from the cron... Ex: ./mywrapper.sh "/usr/bin/ps -ef |... (1 Reply)
Discussion started by: sumgi
1 Replies

6. AIX

Redirecting Both to a file and std output

Hello Friends, Can some one help me how to redirect output of a file to both a file and std output? All the help would be greatly appreciated. Regards Sridhar (1 Reply)
Discussion started by: send2sridhar
1 Replies

7. AIX

Creating a pointer to std::istrstream is giving error

Hi I my code i have following statement std::istrstream *m_poIstream; when i compile with xlC_r verison 8 compiler throws following error : 1540-0063 (S) The text "*" is unexpected.* Any idea/pointers from nayeem khan (0 Replies)
Discussion started by: khan_069
0 Replies

8. Programming

Sun Studio C++ - Getting error in linking std::ostream &std::ostream::operator<<(std:

Hello all Im using CC: Sun C++ 5.6 2004/07/15 and using the -library=stlport4 when linkning im getting The fallowing error : Undefined first referenced symbol in file std::ostream &std::ostream::operator<<(std::ios_base&(*)(std::ios_base&))... (0 Replies)
Discussion started by: umen
0 Replies

9. UNIX for Advanced & Expert Users

Redirecting to Error File

Hi- I want to redirect the output of the echo to the standard error file. We require this because, when we try to scp a file from a source server to a target server we get an error code 1. Later we found that it was due to the .cshrc file which outputs on stdout which is making the scp to fail.... (1 Reply)
Discussion started by: lorcan
1 Replies

10. Shell Programming and Scripting

How to redirect std out and std err to same file

Hi I want both standard output and standard error of my command cmd to go to the same file log.txt. please let me know the best commandline to do this. Thanks (2 Replies)
Discussion started by: 0ktalmagik
2 Replies
Login or Register to Ask a Question