Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running a command after a pipe causes Broken Pipe error

Status
Not open for further replies.

motoslide

MIS
Oct 30, 2002
764
US
I'm sure this is a simple one, but I'm having a problem where I'm trying to run a command inside a script which is only executed after a pipe. For example, here's the script (minimized to isolate the problem):
Code:
who -m | tr -s " " | cut -f5 -d" "|sed 's/(//g'|sed 's/)//g' > $HOME/MYIP
If I run the script, I get my IP address stored in a text file. But, if I run the script like this:
$ echo "TEST" | myscript
I get an empty file in $HOME/MYIP.

To see the actual problem, I get a Broken pipe error on this command:
$ echo "TEST" | who -m

This works in /bin/sh, but not in /bin/bash.

Thanks in advance!

-Rick

"Proof that there is intelligent life in Oregon. Well, Life anyway.
 
Oops. I believe I've misjudged the problem. It has nothing to do with /bin/sh or /bin/bash. This is more related to differences in the "who" implementation between flavors of *NIX.

I'll need a different means to determine the Client IP address.


"Proof that there is intelligent life in Oregon. Well, Life anyway.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top