On Sunday 13 February 2005 05:36 pm, Mark Knecht <[EMAIL PROTECTED]>
wrote:
> Hi again,
> Thanks to everyone who's helped with my little project today. I now
> have a working version of a script that is started by double clicking
> on an icon in Gnome and answering some questions. Cool for me.
> Thanks.
>
> For reference, and because I have one little problem here's the
> script:
>
> #!/bin/bash
> gigdump "$1" | grep Instrument | grep MIDI
>
> echo
> echo Please pick an instrument
> read INSTRUMENT
> echo INSTRUMENT = $INSTRUMENT
>
> echo "ADD CHANNEL" | nc localhost 8888
>
> Within reasonable usage this works just fine. I could add some error
> checking, etc. but it's fine for now. There is only one more thing I
> need to make it really useful. When the output of 'echo "ADD CHANNEL"
> | nc localhost 8888' is executed LinuxSampler returns a channel
>
> number. Here's a pass at using the script:
>
> Instrument 1) "Grand Piano 1", MIDIBank=0, MIDIProgram=0
>
> Please pick an instrument
> 1
> INSTRUMENT = 1
> OK[0]
> OK
> OK
> OK
> OK
>
> >From 1-16 please pick a MIDI channel for this instrument
>
> 1
> OK
> Hook to which alsa_pcm:playback pair?
> 12
> OK
> OK
> ENGINE_NAME: GigEngine
> VOLUME: 0.400
> AUDIO_OUTPUT_DEVICE: 0
> AUDIO_OUTPUT_CHANNELS: 2
> AUDIO_OUTPUT_ROUTING: 0,1
> MIDI_INPUT_DEVICE: 0
> MIDI_INPUT_PORT: 0
> MIDI_INPUT_CHANNEL: 0
> INSTRUMENT_FILE: /home/mark/Gigs/GSt25/Pianos/East
> West/grandpiano1.sf2.gig INSTRUMENT_NR: 0
> INSTRUMENT_NAME: Grand Piano 1
> INSTRUMENT_STATUS: 100
> .
> Hit enter to finish
>
> Note that near the start there is a response
>
> OK[0]
>
>
> The '0' [is] the real channel number that LinuxSampler has
> assigned to my set of commands. I do not know how to capture this
> response back into my script.
>
> Does anyone know how I grab this response?
CHANTEXT=`echo "ADD CHANNEL" | nc localhost 8888 2>&1`
TMP=${CHANTEXT##OK[}
CHANNEL=${TMP%%]}
===
The backticks executes a command and captures its standard out. The "2>&1"
at the end ties stderr to stdout; both would normally get printed to the
screen so I don't know which one it's coming from so I capture both in
CHANTEXT.
Using the braces "{}" with $ allows a few string processing commands to be
appended specifically "##", which is cut maximal matching pattern prefix,
and "%%", which is cut maximal matching pattern suffix.
I use the word pattern above to mean either glob or regex; I'm not sure
which one it is or how full-featured the regex implementation is.
--
Boyd Stephen Smith Jr.
[EMAIL PROTECTED]
ICQ: 514984 YM/AIM: DaTwinkDaddy
--
[email protected] mailing list