Shell redirection doubt


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell redirection doubt
# 1  
Old 10-09-2010
Shell redirection doubt

Hi,

Could anyone explain me why I am getting the 'broken pipe' error for the below?

Code:
exec 3>&1
echo cat | cat <&3

-su: echo: write error: Broken pipe
# 2  
Old 10-09-2010
What are you trying to echo? At the least, you should put quotes around cat | cat <&3. But that will just display it.
# 3  
Old 10-09-2010
I am confused with what it is you are trying to do, but I can answer the question about the pipe.

The echo cat portion of the command is trying to write the command line tokens (cat in this case) to the standard output device. You've piped the standard output device to another command, and if were left at that there'd be no error.

The error is coming as a result of your redirecting standard input to the second command (also cat) which is causing the pipe created for the first command to be invalid. When the echo command attempts to write to the invalid pipe, it receives a 'broken pipe' signal and that is what is being announced.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script output redirection question

OS : AIX 6.1 Shell : Korn in the url https://forums.oracle.com/forums/thread.jspa?threadID=361463&tstart=0 I came across a crontab entry example 00 23 * * 1,3,5 <complete shell script path> 1> <log file> 2>&1 From googling , I gathered that 0 - stdin 1 - stdout 2 - stderr I... (5 Replies)
Discussion started by: polavan
5 Replies

2. Shell Programming and Scripting

Bash shell scripting doubt

Hello All, I am setting up a cron job, where i am calling a shell script to make few builds. I got struck at a point, need some expert inputs to proceed further. The script is categorized in 5 parts and in the last part while building software it asks for few questions like:- 1. Build mode... (4 Replies)
Discussion started by: sahil_jammu
4 Replies

3. Shell Programming and Scripting

Help with Output Redirection of a Unix Shell Script

Hi Guys, I have a script for which the stdout and stderr should be redirected to a log file, they should not be printed on the screen. Could you please let me know the procedure to redirect the output of the script to a log file. Thanks in advance. --- Aditya (5 Replies)
Discussion started by: chaditya
5 Replies

4. Shell Programming and Scripting

Unix shell output redirection help

Hi all, Actually i need to know whether there is any way to redirect the output of shell operations into any file without pipe . Actually my problem is , i run some command & its result is displayed on shell after some calculations on shell, so if i redirect its output to file, it is not... (5 Replies)
Discussion started by: sarbjit
5 Replies

5. UNIX for Advanced & Expert Users

shell redirection in find

hi, i need to clear data off a DOA backup drive. i try this, but just get a file {} in . and no change on the backup drive. bash shell find /mnt/usbbackup -xdev -type f -exec echo `date` > {} \; any ideas? thanks. :) (1 Reply)
Discussion started by: drewnichols
1 Replies

6. Shell Programming and Scripting

shell script doubt

Hi, While reading a shell script ,i have come accross the following statements. script_name_full=$0 ***script_name=${script_name_full##*\} ***script_name_noexst=${script_name%%\.ksh} host_name=`hostname` ***host_name_short=${host_name%%\.*} can anybody tell me what is the purpose of marked... (5 Replies)
Discussion started by: ravi raj kumar
5 Replies

7. Shell Programming and Scripting

Asking about shell script input output redirection

Hi, Can anyone please tell me what these lines do? ls >& outfile ls outfile 2>&1 Thanks. (1 Reply)
Discussion started by: trivektor
1 Replies

8. Shell Programming and Scripting

Shell scripting basic doubt

Hi, I have a script called sam.sh which consists of a single echo statement like this #/usr/bin/ksh echo "Mani" I changed the mode for the script by giving chmod a+x sam.sh. If I want to execute the scrpt by just giving the name at the command line "sam.sh", what should I necessarily do?... (3 Replies)
Discussion started by: sendhilmani123
3 Replies

9. Shell Programming and Scripting

Miniature Shell - IO Redirection and Pipe line filters

hi, I was trying to write a miniature shell (ie, command line interpreter) to implement the features like 'IO Redirection' and 'Pipe line fileters'. Can anyone help me with sample shell sript to implement the above features. cheers supong (2 Replies)
Discussion started by: supong
2 Replies

10. UNIX for Advanced & Expert Users

shell / awk doubt

Hi all, I have a ascii text file like this : $cat a.txt abc |12343 |xyakdfj | x |323 || kr1 |13434343|234343 | Is it possible to to get the file eleminating blank spaces? output file : abc|12343|xyakdfj| x|323||... (7 Replies)
Discussion started by: krishna
7 Replies
Login or Register to Ask a Question