Ok, I can't seem to figure this out or find anything on the web about this.
I'm on Sun Solaris, UNIX.
I have the following test script:
which hangs on the final echo command when I run it.
Interestingly, if I comment out the ls, or either echo command, it works fine.
So I'm trying to understand what's happening here. Hoping somebody could explain?
What I'm trying to do:
- capture stdout and stderr into a log file. [edit] correction: want to capture stdout and sterr to both display and log file[/edit]
- need to capture the return code of the command as well (ie $?) (hence why I'm mucking around with PIPE's so I can displace the tee command).
It seems to work sometimes, and then hang on other occasions, and I haven't found a pattern to it yet.
Hoping anyone can shed light on this - or provide a suitable work around.
Thanks!
[edit]
more specific version info:
Sun4u sparc SUNW
SPARC-Enterprise SunOS
5.10
uname -v
returns:
Generic_147440-02
[/edit]
[edit]
Seems as soon as I do an ls, cp, mv or other disk access, it hangs on the next command?
[/edit]
Last edited by Ditto; 03-19-2014 at 06:19 PM..
Reason: version
What return code are you trying to capture?
What are you trying to capture in the log file? (What you have seems to want to capture the output from the echo commands, but not the output from the ls command.)
It would seem that:
would be much simpler than what you're doing and produce the same results.
What return code are you trying to capture?
What are you trying to capture in the log file? (What you have seems to want to capture the output from the echo commands, but not the output from the ls command.)
It would seem that:
would be much simpler than what you're doing and produce the same results.
I want to display output and stderr to both display and the log file. [edit] sorry, original post forgot to mention display [/edit]
I need to use tee for that.
I also want to capture the return code of each command (ie echo, ls, cp, whatever). If I use:
<command> 2>&1 |tee -a <log>
then when I check $? I get the return code for tee.
So I found the logic for named pipes, and the above example seemed to work most of the time.
Then I hit this "side case?" Not really sure.
FYI: I did just find something on the web that helped.
Changed my code to this (added the exec), and now it works
(soo confused. )
From what I understand, the named pipe thinks that after the ls (or cp, or mv), that I'm all done with it. (this occurs whether I send the output of the ls, cp, or mv to the PIPE or not). By throwing the exec 5>$PIPE in there, it seems to trick it into expecting more input ???
...which hangs on the final echo command when I run it.
The shell tries to open the pipe before it puts the command in background, and freezes waiting for it. You have to put it in a separate subshell to avoid this.
It still hangs, until the other end opens, but it's some other shell hanging, not yours.
The shell tries to open the pipe before it puts the command in background, and freezes waiting for it. You have to put it in a separate subshell to avoid this.
Yes, the tee command, I run using & to throw into background.
As I indicated, if you comment out the ls (which seems to have nothing to do with the PIPE - it works fine - no hang.
With the script as is - the first echo makes it into the pipe, the ls works fine - displays to screen only.
then the last echo just hangs. Yes - my script is hanging.
Quote:
What is your goal here, though?
What I'm trying to do:
- want to capture stdout and sterr to both display and log file
- need to capture the return code of the command as well (ie $?) (hence why I'm mucking around with PIPE's so I can displace the tee command).
Hi All !
I try to collect importent events from syslog and in my
syslog conf, there is something like this:
*.* |/logs/ipes/SLpipe1
I have a program, which opens this pipe and reads the messages from it.
But how this pipe works ? Where can I probably read something about the details,... (3 Replies)
Hi,
I am getting data into a Named pipe. Does Named pipe have any size restriction; I know it does not have any storage and it just passes on the data to the next process.
I want to know, if there will be a difference in the Named pipe performance if the data input is more. (I am using DB2... (1 Reply)
Hi,
I want to use a Named pipe to get input from a growing file for further processing. When I prototype this scenario using a while loop, the data is not written to the named pipe.
This the script I use to get data into the Named pipe:
#!/bin/ksh
mkfifo pipe
while (( n <= 10 ))
do
echo... (2 Replies)
I would like to pipe (redirect ? - what is the right term?) the output of my script to a file named with the current date.
If I run this at a command prompt:
date +'%Y%m%d"
...it returns "20110429"
OK, that's good... so I try:
./script.sh > "'date +%Y%m%d'.csv"
I get a file... (1 Reply)
Hello,
On my machine, all mail is stored in my /var/spool/mail.
IS there a way to direct all mail that goes there into a namep pipe?
Thank you,
Dado (4 Replies)
I want to copy the contents of a named pipe to a file. I have tried using:
cat pipe.p >> transcript.log
but I have been unsuccessful, any ideas? (4 Replies)
Gurus,
I've a File Transaction Server, which communicates with other servers and performs some processing.It uses many Named PIPE's.
By mistake i copied a named PIPE into a text file.
I heard that PIPE files shouldn't be copied.Isn't it?
Since it's a production box, i'm afraid on... (2 Replies)
Hi All,
I am facing a vague issue while trying to make two process talk to each
other using named pipe.
read process
=========
The process which reads, basically creates FIFO using
mkfifo - ret_val = mkfifo(HALF_DUPLEX, 0666) func.
It then opens the pipe using open func - fd = open... (2 Replies)
Hi All,
I am facing a vague issue while trying to make two process talk to each
other using named pipe.
read process
=========
The process which reads, basically creates FIFO using
mkfifo - ret_val = mkfifo(HALF_DUPLEX, 0666);) func.
It then opens the pipe using open func - fd =... (1 Reply)