How to redirect std err and out to log file for multi-commands?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to redirect std err and out to log file for multi-commands?
# 1  
Old 08-10-2007
How to redirect std err and out to log file for multi-commands?

The following command does not work under cygwin bash.

ant debug >log 2>&1 && ant image >>log 2>>&1 & pid=$!

It gives the error "-bash: sysntax error near unexpected token '&'".

Is there a way I can redirect std output and std error to file "log" for both the commands "ant debug" and "ant image"?

Thanks,
siegfried
# 2  
Old 08-10-2007
Try having a line break between the "&" and "pid=$!"
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Keeping std & err outputs alive and feed one log file in a one-shot way

Bonjour, I have a large script with a lot of print statements and misc commands. Standard and error outputs are redirected like into the following code : #!/usr/bin/ksh LOG=/<some dir>/log > $LOG exec >>${LOG} 2>>${LOG} print aaaaa print bbbbb print ccccc ... some_cmd That way,... (5 Replies)
Discussion started by: Fundix
5 Replies

2. Shell Programming and Scripting

ksh view std err state

I would like to know if a command works. "command" 2>/dev/null When I issue the command, the error is suppressed. How can I tell whether there was an error? (3 Replies)
Discussion started by: robin_simple
3 Replies

3. Shell Programming and Scripting

Ksh script: std Out/err

Hello gurus, this is part of my script: ls -1 ${MyFile} >> ${dir_log}ListFile${Now}.tmp FILENUM=`cat ${dir_log}ListFile${Now}.tmp| wc -l | awk '{print $1}'`>> /dev/null if then writeError "ERRORE: no file in directory for type ${FileName}!" >> ${LogFileName} Close 1 fi... (7 Replies)
Discussion started by: GERMANICO
7 Replies

4. Shell Programming and Scripting

redirect LVM commands to file in Red Hat

I have been trying to create a little script to direct system configuration information to a file, however when I run LVM commands (vgdisplay, lvdisplay...etc) nothing appears in my output file. This is what I currently have in my script: vgdisplay >> sysinfo.out everthing else seems to... (0 Replies)
Discussion started by: Alvescot
0 Replies

5. Programming

Redirect Standard Output Multi-Process

Hi, I'm trying to compile the following code: /************** Begin <test.c> ***************/ /* * Compiled with: gcc -Wall -o test test.c */ #include <stdio.h> #include <unistd.h> int main(void) { printf("I'm process %d, son of %d \n", getpid(), getppid()); ... (5 Replies)
Discussion started by: djodjo
5 Replies

6. UNIX for Advanced & Expert Users

redirect to both file and std output at the same time

hello can some one please help me to redirect the output of a command to both std output and a file. this is little urgent. sridhar (2 Replies)
Discussion started by: send2sridhar
2 Replies

7. AIX

Can I display err log again after run errclear

After run errclear, it will clean the err log file. After that, if I still need display the log has been cleared by errclear, how can I do? thanks (5 Replies)
Discussion started by: rainbow_bean
5 Replies

8. Programming

Redirect Output Multi-Process

Hi, I'm trying to compile the following code: /************** Begin <test.c> ***************/ /* * Compiled with: gcc -Wall -o test test.c */ #include <stdio.h> #include <unistd.h> int main(void) { printf("I'm process %d, son of %d \n", getpid(), getppid()); printf("Hello \n");... (3 Replies)
Discussion started by: djodjo
3 Replies

9. 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

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