Re: [gentoo-user] OT: Running something complicated from Gnome's browser
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 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 ' 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 21` TMP=${CHANTEXT##OK[} CHANNEL=${TMP%%]} === The backticks executes a command and captures its standard out. The 21 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 -- gentoo-user@gentoo.org mailing list
[gentoo-user] OT: Running something complicated from Gnome's browser
Hi, This is not a Gentoo thing at all but I don't know where else to ask so I'm coming here. Delete if you're not interested. I have a suspicion this is some big scripting job. Scripting to any great extent is something I know nothing about. I'm hoping that maybe someone can point me in the right direction. Thanks in advance. Within Gnome is there a way that I could double click on a file in their browser and then cause the system to start executing a program that asks me questions about what to do? I have some files that are used in a specialized audio program. Each individual file contain multiple instruments. I'd like the script to: 1) Check the file for available instruments. I know how to do this (sort of) at the command line using something like gigdump filename.gig | grep Instrument. That almost works well enough for this task but it does produce one extra line I'll need to get rid of. 2) Pop up a window and tell me about the instrument list 3) Ask me which on I want to use 4) Ask me a couple more questions that I answer 5) Take the set of answers and send it over the network using some command like echo command 1 | nc localhost echo command 2 | nc localhost I know nothing of doing stuff like this but it would be very helpful. The windows program that uses these files of course has a fancy file browser that allows you to do this with a couple of click drag operations. The Linux program has nothing so I'm doing this by hand and it's very tedious. Thanks for taking the time to read and possibly respond. Cheers, Mark -- gentoo-user@gentoo.org mailing list
Re: [gentoo-user] OT: Running something complicated from Gnome's browser
El dom, 13-02-2005 a las 10:22 -0800, Mark Knecht escribió: Hi, This is not a Gentoo thing at all but I don't know where else to ask so I'm coming here. Delete if you're not interested. I have a suspicion this is some big scripting job. Scripting to any great extent is something I know nothing about. I'm hoping that maybe someone can point me in the right direction. Thanks in advance. Within Gnome is there a way that I could double click on a file in their browser and then cause the system to start executing a program that asks me questions about what to do? I have some files that are used in a specialized audio program. Each individual file contain multiple instruments. I'd like the script to: 1) Check the file for available instruments. I know how to do this (sort of) at the command line using something like gigdump filename.gig | grep Instrument. That almost works well enough for this task but it does produce one extra line I'll need to get rid of. 2) Pop up a window and tell me about the instrument list 3) Ask me which on I want to use 4) Ask me a couple more questions that I answer 5) Take the set of answers and send it over the network using some command like echo command 1 | nc localhost echo command 2 | nc localhost I know nothing of doing stuff like this but it would be very helpful. The windows program that uses these files of course has a fancy file browser that allows you to do this with a couple of click drag operations. The Linux program has nothing so I'm doing this by hand and it's very tedious. Thanks for taking the time to read and possibly respond. i made my own auto-decompresser with python-gtk (i dont use file-roller), it uses file to get file type and select with command to use and showme the output. in module commands you get commands.getoutput, with this you can get stdout of a program to analize. also you can use zenity to make dialogs and catch their output codes, its a program that makes dialogs. i don't know gigdump but matbe it have some parameter to give short output, also you can use string.replace. -- gentoo-user@gentoo.org mailing list
Re: [gentoo-user] OT: Running something complicated from Gnome's browser
On Sun, 13 Feb 2005 10:22:36 -0800, Mark Knecht [EMAIL PROTECTED] wrote: Within Gnome is there a way that I could double click on a file in their browser and then cause the system to start executing a program that asks me questions about what to do? I don't know what you mean by their browser. In Firfox and all the mozilla/netscape derivatives, you can establish Mime relationships that cause a program or script to be invoked when you click (single click is enough) on a file with the registered file type. From the description below, the registered program would need to be a moderately complex script. I have some files that are used in a specialized audio program. Each individual file contain multiple instruments. I'd like the script to: 1) Check the file for available instruments. I know how to do this (sort of) at the command line using something like gigdump filename.gig | grep Instrument. That almost works well enough for this task but it does produce one extra line I'll need to get rid of. In a bash script you can easily pipe the output of your `gigdump filename.gig | grep Instrument` (note the backticks rather than quotes) commands into variables and iterate through these. 2) Pop up a window and tell me about the instrument list. 3) Ask me which on I want to use 4) Ask me a couple more questions that I answer All of this is doable in a script. 5) Take the set of answers and send it over the network using some command like echo command 1 | nc localhost echo command 2 | nc localhost Also not a problem in a script. I know nothing of doing stuff like this but it would be very helpful. The windows program that uses these files of course has a fancy file browser that allows you to do this with a couple of click drag operations. The Linux program has nothing so I'm doing this by hand and it's very tedious. Yes, Linux does not have a builtin script to do this, but you can roll your own. The question is: are you ready to learn bash or perl or python or php or ??? and to do a little research to build your knowledge of the browser interface and the use of these tools? A little knowledge can be a dangerous thing. -- Collins -- gentoo-user@gentoo.org mailing list
Re: [gentoo-user] OT: Running something complicated from Gnome's browser
On Sun, 13 Feb 2005 16:02:32 +, rodrigo ahumada [EMAIL PROTECTED] wrote: i made my own auto-decompresser with python-gtk (i dont use file-roller), it uses file to get file type and select with command to use and showme the output. in module commands you get commands.getoutput, with this you can get stdout of a program to analize. also you can use zenity to make dialogs and catch their output codes, its a program that makes dialogs. i don't know gigdump but matbe it have some parameter to give short output, also you can use string.replace. Is that script something you could share off list? I've gotten as far as double clicking on the file's icon and getting it to run a bash file but I'm not getting the filename into the bash file so the results are useless so far. Thanks, Mark -- gentoo-user@gentoo.org mailing list
Re: [gentoo-user] OT: Running something complicated from Gnome's browser
On Sunday 13 February 2005 12:22 pm, Mark Knecht [EMAIL PROTECTED] wrote: Hi, This is not a Gentoo thing at all but I don't know where else to ask so I'm coming here. Delete if you're not interested. I have a suspicion this is some big scripting job. Scripting to any great extent is something I know nothing about. I'm hoping that maybe someone can point me in the right direction. Thanks in advance. Within Gnome is there a way that I could double click on a file in their browser and then cause the system to start executing a program that asks me questions about what to do? I have some files that are used in a specialized audio program. Each individual file contain multiple instruments. I'd like the script to: You'll have to check some gnome-dev documentation, but generally file system browsers execute external program by running a simple command line. There may be variable in the command-line. Perhaps %f for the name of the file of somesuch. 1) Check the file for available instruments. I know how to do this (sort of) at the command line using something like gigdump filename.gig | grep Instrument. That almost works well enough for this task but it does produce one extra line I'll need to get rid of. If you can get it to execute a bash script, the command-line aruments are avilable through $number variables. $0 is how the script was invoked on the command line; $1 is the first command-line argument, etc. 2) Pop up a window and tell me about the instrument list While bash has no support for this, you may be able to use GTK binding for some scipting language Perl/Python to do this. Your first stop for this step is the GTK documentation/tutorial. 3) Ask me which on I want to use 4) Ask me a couple more questions that I answer Reapeat steps 2-3; If you want to show a GUI and you are already running gnome, you'll want to learn/use GTK. 5) Take the set of answers and send it over the network using some command like echo command 1 | nc localhost echo command 2 | nc localhost Most languages will allow you to execute commands like this with some call. This is all bash does; perl has backticks and a few system calls; python and C also have system calls. You may not even need to have the shell do the piping, as you generally get/provide some handle to/for the stdin/out/err of a subprocess. I know nothing of doing stuff like this but it would be very helpful. The windows program that uses these files of course has a fancy file browser that allows you to do this with a couple of click drag operations. The Linux program has nothing so I'm doing this by hand and it's very tedious. Well, do get this done you are going to have to learn a bit. Since you need some degree of GUI interaction, you'll probably want to go with perl or python for the actual script. If you have pervious experience with shell scripting or perl, go that way. If not, go the python way, then you'll know the language portage is written in and can do some serious gentoo hacking. ;) -- Boyd Stephen Smith Jr. [EMAIL PROTECTED] ICQ: 514984 YM/AIM: DaTwinkDaddy -- gentoo-user@gentoo.org mailing list
Re: [gentoo-user] OT: Running something complicated from Gnome's browser
On Sun, 13 Feb 2005 14:44:02 -0600, Boyd Stephen Smith Jr. [EMAIL PROTECTED] wrote: On Sunday 13 February 2005 12:22 pm, Mark Knecht [EMAIL PROTECTED] wrote: Hi, This is not a Gentoo thing at all but I don't know where else to ask so I'm coming here. Delete if you're not interested. I have a suspicion this is some big scripting job. Scripting to any great extent is something I know nothing about. I'm hoping that maybe someone can point me in the right direction. Thanks in advance. Within Gnome is there a way that I could double click on a file in their browser and then cause the system to start executing a program that asks me questions about what to do? I have some files that are used in a specialized audio program. Each individual file contain multiple instruments. I'd like the script to: You'll have to check some gnome-dev documentation, but generally file system browsers execute external program by running a simple command line. There may be variable in the command-line. Perhaps %f for the name of the file of somesuch. 1) Check the file for available instruments. I know how to do this (sort of) at the command line using something like gigdump filename.gig | grep Instrument. That almost works well enough for this task but it does produce one extra line I'll need to get rid of. If you can get it to execute a bash script, the command-line aruments are avilable through $number variables. $0 is how the script was invoked on the command line; $1 is the first command-line argument, etc. Right. Thanks. I'm now passing the filename to the scipt correctly. 2) Pop up a window and tell me about the instrument list While bash has no support for this, you may be able to use GTK binding for some scipting language Perl/Python to do this. Your first stop for this step is the GTK documentation/tutorial. Gnome allows me to run my bash script in a terminal so now the terminal pops up, runs gigdump, greps out the right lines and saves them to a temp file. I then cat that file to the same terminal and see the results. Good so far. 3) Ask me which on I want to use Easy to make it ask the question but so far I cannot find the bash command to wait for keyboard input. There must be one but I don't see it in man bash. 4) Ask me a couple more questions that I answer Reapeat steps 2-3; If you want to show a GUI and you are already running gnome, you'll want to learn/use GTK. Not into GUI programming today. Just want to see if I can get it to work. If it does then and it's useful then maybe I'll make a GUI next Sunday afternoon. 5) Take the set of answers and send it over the network using some command like echo command 1 | nc localhost echo command 2 | nc localhost Most languages will allow you to execute commands like this with some call. This is all bash does; perl has backticks and a few system calls; python and C also have system calls. You may not even need to have the shell do the piping, as you generally get/provide some handle to/for the stdin/out/err of a subprocess. Oops - that was beyond my skill level... I know nothing of doing stuff like this but it would be very helpful. The windows program that uses these files of course has a fancy file browser that allows you to do this with a couple of click drag operations. The Linux program has nothing so I'm doing this by hand and it's very tedious. Well, do get this done you are going to have to learn a bit. Since you need some degree of GUI interaction, you'll probably want to go with perl or python for the actual script. If you have pervious experience with shell scripting or perl, go that way. If not, go the python way, then you'll know the language portage is written in and can do some serious gentoo hacking. ;) I'm actually pretty happy if I can pick an instrument out of the list that the gigdump command gives me and then just tell nc to load it in LinuxSampler. Jsut happening in an xterm is fine for me. Thanks, MArk -- gentoo-user@gentoo.org mailing list
Re: [gentoo-user] OT: Running something complicated from Gnome's browser
quoth the Mark Knecht: On Sun, 13 Feb 2005 14:44:02 -0600, Boyd Stephen Smith Jr. snip 3) Ask me which on I want to use Easy to make it ask the question but so far I cannot find the bash command to wait for keyboard input. There must be one but I don't see it in man bash. This is easy, here's an example: echo What is you name? read NAME echo Your name is ${NAME} So basically whatever the user types will be put in the value of the variable following 'read' more snip -d -- darren kirby :: Part of the problem since 1976 :: http://badcomputer.org ...the number of UNIX installations has grown to 10, with more expected... - Dennis Ritchie and Ken Thompson, June 1972 pgpr9CjklWVeB.pgp Description: PGP signature
Re: [gentoo-user] OT: Running something complicated from Gnome's browser
On Sunday 13 February 2005 03:31 pm, Mark Knecht [EMAIL PROTECTED] wrote: On Sun, 13 Feb 2005 14:44:02 -0600, Boyd Stephen Smith Jr. [EMAIL PROTECTED] wrote: On Sunday 13 February 2005 12:22 pm, Mark Knecht [EMAIL PROTECTED] wrote: 2) Pop up a window and tell me about the instrument list While bash has no support for this, you may be able to use GTK binding for some scipting language Perl/Python to do this. Your first stop for this step is the GTK documentation/tutorial. Gnome allows me to run my bash script in a terminal so now the terminal pops up, runs gigdump, greps out the right lines and saves them to a temp file. I then cat that file to the same terminal and see the results. Good so far. 3) Ask me which on I want to use Easy to make it ask the question but so far I cannot find the bash command to wait for keyboard input. There must be one but I don't see it in man bash. The bash command read will read one line on text into a variable you use it like: read foo; echo $foo; 4) Ask me a couple more questions that I answer Reapeat steps 2-3; If you want to show a GUI and you are already running gnome, you'll want to learn/use GTK. Not into GUI programming today. Just want to see if I can get it to work. If it does then and it's useful then maybe I'll make a GUI next Sunday afternoon. Well, if you've got a terminal window you should be able to mess around with bash to do simple stuff. I think there's also some prompt command for bash that lets you choose one item from a list. I really haven't gotten into interactive bash scripting. But, it's all there in info bash, I suppose. I wasn't even sure nautalus/konqueror would open up a terminal window for the command. 5) Take the set of answers and send it over the network using some command like echo command 1 | nc localhost echo command 2 | nc localhost Most languages will allow you to execute commands like this with some call. This is all bash does; perl has backticks and a few system calls; python and C also have system calls. You may not even need to have the shell do the piping, as you generally get/provide some handle to/for the stdin/out/err of a subprocess. Oops - that was beyond my skill level... Well, in bash you can do stuff like var=`cat myfile` to execute cat myfile, capture it's output and stick it in var. You can do similar stuff with perl. Also, most language have something like C's system() call so that you can do: system(./my_helper_script.sh); with syntax appropriate to the language, but it's quite different from using baskticks: By default the subprogram uses the same stdin/out/err and you don't really get a whole lot of information back into the calling program. Anyway, if you want to do it in bash, you won't have to worry about this much, if at all. -- Boyd Stephen Smith Jr. [EMAIL PROTECTED] ICQ: 514984 YM/AIM: DaTwinkDaddy -- gentoo-user@gentoo.org mailing list
Re: [gentoo-user] OT: Running something complicated from Gnome's browser
On Sun, 13 Feb 2005 15:48:02 -0600, Boyd Stephen Smith Jr. [EMAIL PROTECTED] wrote: On Sunday 13 February 2005 03:31 pm, Mark Knecht [EMAIL PROTECTED] wrote: SNIP 3) Ask me which on I want to use Easy to make it ask the question but so far I cannot find the bash command to wait for keyboard input. There must be one but I don't see it in man bash. The bash command read will read one line on text into a variable you use it like: read foo; echo $foo; 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 echo LOAD ENGINE gig 0 | nc localhost echo SET CHANNEL AUDIO_OUTPUT_DEVICE 0 0 | nc localhost echo LOAD INSTRUMENT \$1\ $(($INSTRUMENT-1)) 0 | nc localhost echo SET CHANNEL VOLUME 0 0.40 | nc localhost echo From 1-16 please pick a MIDI channel for this instrument read MIDI echo SET CHANNEL MIDI_INPUT 0 0 0 $(($MIDI-1)) | nc localhost echo Hook to which alsa_pcm:playback pair? read JACK echo SET AUDIO_OUTPUT_CHANNEL_PARAMETER 0 0 JACK_BINDINGS='alsa_pcm:playback_$JACK' | nc localhost echo SET AUDIO_OUTPUT_CHANNEL_PARAMETER 0 1 JACK_BINDINGS='alsa_pcm:playback_$(($JACK+1))' | nc localhost echo GET CHANNEL INFO 0 | nc localhost echo Hit enter to finish read WAIT 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 ' 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] Note that if I load a second gig file then LinuxSampler returns a new channel number: Instrument 1) Dyno Rhodes, MIDIBank=0, MIDIProgram=0 Please pick an instrument 1 INSTRUMENT = 1 OK[1] OK OK OK OK From 1-16 please pick a MIDI channel for this instrument The '0' '1' are the real channel numbers 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? Thanks, Mark -- gentoo-user@gentoo.org mailing list
Re: [gentoo-user] OT: Running something complicated from Gnome's browser
On Sun, 13 Feb 2005 15:48:02 -0600, Boyd Stephen Smith Jr. [EMAIL PROTECTED] wrote: On Sunday 13 February 2005 03:31 pm, Mark Knecht [EMAIL PROTECTED] wrote: 2) Pop up a window and tell me about the instrument list While bash has no support for this, you may be able to use GTK binding for some scipting language Perl/Python to do this. Your first stop for this step is the GTK documentation/tutorial. Gnome allows me to run my bash script in a terminal so now the terminal pops up, runs gigdump, greps out the right lines and saves them to a temp file. I then cat that file to the same terminal and see the results. Good so far. 3) Ask me which on I want to use 4) Ask me a couple more questions that I answer If you want a simple pseudo-gui textmode system to let you display simple menus and make choices in bash, google for information about 'dialog'. You can create a simple structure to do what you want. It looks very much like the panels in the Slackware installer, if you've ever seen that. -- Collins -- gentoo-user@gentoo.org mailing list
Re: [gentoo-user] OT: Running something complicated from Gnome's browser
El dom, 13-02-2005 a las 15:36 -0800, Mark Knecht escribió: The '0' '1' are the real channel numbers that LinuxSampler has assigned to my set of commands. I do not know how to capture this response back into my script. what if you try: OUTPUT=`echo ADD CHANNEL | nc localhost ` or OUTPUT=$(echo ADD CHANNEL | nc localhost ) -- gentoo-user@gentoo.org mailing list
Re: [gentoo-user] OT: Running something complicated from Gnome's browser
On Sun, 13 Feb 2005 21:26:43 +, rodrigo ahumada [EMAIL PROTECTED] wrote: El dom, 13-02-2005 a las 15:36 -0800, Mark Knecht escribió: The '0' '1' are the real channel numbers that LinuxSampler has assigned to my set of commands. I do not know how to capture this response back into my script. what if you try: OUTPUT=`echo ADD CHANNEL | nc localhost ` or OUTPUT=$(echo ADD CHANNEL | nc localhost ) Thanks for the ideas. They didn't seem to work. I'll keep looking around. - Mark -- gentoo-user@gentoo.org mailing list