Results 1 to 10 of 15
I am working on Shell script but on Solaris server (/bin/ksh is default) and not able to redirect the Std Err and Std Output to a file..following is my code
...
- 04-04-2008 #1Linux Newbie
- Join Date
- Jan 2008
- Posts
- 114
How can we redirect std err and std ouput in KSH
I am working on Shell script but on Solaris server (/bin/ksh is default) and not able to redirect the Std Err and Std Output to a file..following is my code
ssh hostname | grep "omega" /home/ >& test.log
nothing is going in test.logSwitched to Scripting
- 04-04-2008 #2
Try this:
Code:ssh hostname | grep "omega" /home/ 1> test.log 2>&1
- 04-04-2008 #3Linux Newbie
- Join Date
- Jan 2008
- Posts
- 114
still not writing in a file
Switched to Scripting
- 04-04-2008 #4
- 04-04-2008 #5Linux Newbie
- Join Date
- Jan 2008
- Posts
- 114
test.log file has to be created at runtime and I am able to see error message on the screen but it should store in to the test.log.
error message was "connection refused"Switched to Scripting
- 04-04-2008 #6
- 04-04-2008 #7Linux Newbie
- Join Date
- Jan 2008
- Posts
- 114
Ohhh sorry misunderstood.
But is there any way so that I can store that output too in a log file?Switched to Scripting
- 04-04-2008 #8
I guess you could try the following:
to get all error and output from both commands into the log but I'm not sure if that will work. I don't have ssh installed on the machine I test ksh with so I can't test it. Maybe one of the scripting gurus will chime in.Code:ssh hostname 1> test.log 2>&1 | grep "omega" /home/ 1>> test.log 2>&1
- 04-04-2008 #9
Now that I think about it, my last recommendation won't work as the output will be written to the log file. Do you have to authenticate to this machine or is it public key auth?
- 04-04-2008 #10


Reply With Quote
