two bash scripting questions

Mark Knecht markknecht at gmail.com
Mon Feb 14 17:26:11 UTC 2005


Hi,
   I've built a little bash script that does some music stuff for me
in Gnome. I've set a mime type in Gnome so that I can click on certain
files, a terminal opens, the script runs, I answer some questions and
the script makes the music server do some things. It works well, as
far as it goes, but there are a couple of things I couldn't figure out
on Sunday.

1) If I run a generic command that talks to a music server in a
terminal I get a response of OK. I'd like to capture this OK, vs. the
other possibilities or WARN or ERR, and take action based on that
response. How can I do this in a script?

2) In the case of the command that adds channels to my server I get a
response that has the channel number buried in the OK, such as OK[3]
telling me the ADD CHANNEL command completed and the new channel is
number 3. How can I capture this number for use in the script? The
normal command sequence here might look like

echo "ADD CHANNEL" | nc localhost 8888

and I receive 

OK[3] back in the terminal. I tried some things like

OUTPUT=`echo "ADD CHANNEL" | nc localhost 8888`

and

OUTPUT=$(echo "ADD CHANNEL" | nc localhost 8888)

but they didn't work.

   The script is small. It's attached in case there are better ways to
do this stuff that people want to share.

Thanks much,
Mark




More information about the Redhat-install-list mailing list