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):
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.
Code:
who -m | tr -s " " | cut -f5 -d" "|sed 's/(//g'|sed 's/)//g' > $HOME/MYIP
$ 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.