Need help redirecting output to a file including errors


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help redirecting output to a file including errors
# 8  
Old 10-09-2011
using &>filename will redirect your STDIN adn STDERR to given filename.
# 9  
Old 10-09-2011
Ahamed...The syntax works for me...
Code:
$ echo "`ls -ltr | awk 'NR!=1 && NR!=2 {print $9}'`"
list
list.sort
sudo.out
tcp.out
X11.out
open.out
AX.out
AY.out


Last edited by Franklin52; 10-10-2011 at 03:18 AM.. Reason: Please use code tags, thank you
# 10  
Old 10-09-2011
Can you execute push.ksh in the remote server manually and see if it working? In case there are any errors. paste the output of

Code:
bash -x push.ksh

--ahamed
# 11  
Old 10-09-2011
push.ksh itslef runs successfuly on the remote server as seen below, I ran it for both the instances success and error (by including the line in red to test the error part) and run.ksh executes locally its if..then..else conditions based on the result of push.ksh on remote server.

Code:
$ bash -x push.ksh
++ uname -n
+ echo testserver
testserver
++ ls -ltr
++ awk 'NR!=1 && NR!=2 {print $9}'
list
list.sort
sudo.out
tcp.out
X11.out
open.out
AX.out
AY.out
push.ksh
+ '[' 0 -ne 0 ']'
+ echo 'INFO: Files listed successfully'
INFO: Files listed successfully



$ bash -x push.ksh
++ uname -n
+ echo testserver
testserver
list
list.sort
sudo.out
tcp.out
X11.out
open.out
AX.out
AY.out
+ ls -l /jdfkds
ls: 0653-341 The file /jdfkds does not exist.
+ '[' 2 -ne 0 ']'
+ echo 'ERROR: Unable to list files'
ERROR: Unable to list files

Moderator's Comments:
Mod Comment Video tutorial on how to use code tags in The UNIX and Linux Forums.

Last edited by Franklin52; 10-10-2011 at 03:18 AM.. Reason: Please use code tags, thank you
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Redirecting output to file

Hi, I have created script which redirect the output to file.I am able to get the output in file but not in the format. Output :Content of the log which have 10 -15 lines. Actal :Line1 ..Line 2Line3 Line4 Line 5 Expected:Line1 Line 2 Line3 Please... (7 Replies)
Discussion started by: karthik771
7 Replies

2. UNIX for Dummies Questions & Answers

Help with redirecting output to an HTML file

I'm very new to shell scripting and am practicing how to write a script, then redirect the output into an HTML file, and then email both the script and the HTML file to myself. I have created a script called sysinfo_page, and thought it would have redirected the output into the sysinfo_page.html... (3 Replies)
Discussion started by: braing
3 Replies

3. UNIX for Dummies Questions & Answers

redirecting the script output to more than 1 file

Hi, I want to redirect my script output to more than one file without printing the result to the screen. How to do that? ex: echo "hi" >> a.txt b.txt cat a.txt hi b.txt :confused: (2 Replies)
Discussion started by: boopathyvasagam
2 Replies

4. Shell Programming and Scripting

Redirecting output to file

Hi, Below is the whole string which is to be redirected to the new file. su - oracle -c "exp $user/$pass file=/oracle/oradata/backup/exp_trn_tables_`date +%d_%b_20%y_%H_%M_%S`.dmp log=/oracle/oradata/backup/exp_trn_tables_`date +%d_%b_20%y_%H_%M_%S`.log tables=table1,table2 statistics=none" ... (3 Replies)
Discussion started by: milink
3 Replies

5. Shell Programming and Scripting

Redirecting output of Make to file

Hi, I am unable to get this script to work as desired. Basically, if an argument "log" is sent into the script, it outputs the result of the Make to a file output.log. However, if the argument is not passed, I want the output to be just put on screen (no redirection). See code snippet below. #... (3 Replies)
Discussion started by: srujan45
3 Replies

6. Shell Programming and Scripting

Redirecting output to both console and to a file

Hi All, Is there a way in Bash we can redirection some output to both console and the file at the same time. ~Parag (2 Replies)
Discussion started by: paragkalra
2 Replies

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

8. Shell Programming and Scripting

Redirecting my output to a specific file

Hi guys am doing some checking inside my script and i want to redirect my output to a specific file for example checking if a move was successfully done and was writing on the screen whether the move was successful or not and now want to write same thing into a file... I am new to shell... (2 Replies)
Discussion started by: Lutchumaya
2 Replies

9. UNIX for Dummies Questions & Answers

redirecting output, including errors

what's the proper syntax to redirect output, including all errors? ls -la > direct.list makes out put file direct.list but if i'm running a script and i want to include the errors, would i type something like: myscript.scr 2> out_list.txt or will that get the errors only? (1 Reply)
Discussion started by: kymberm
1 Replies

10. UNIX for Advanced & Expert Users

redirecting output to file in network

Hi Experts, Is it possible to redirect the output of an unix command to file. when i "telnet" to a remote system and execute the redirection operation, such that the result should outputted to my system. $ telnet IPaddr2 username : zzzzz password : ******** IPaddr2>ls > file <- i... (1 Reply)
Discussion started by: anent
1 Replies
Login or Register to Ask a Question