RunRev and Linux Shell Scripting (...was Re: Record Audio in Rev on Linux OS?)

John Patten johnpatten at mac.com
Fri Apr 23 13:18:25 EDT 2010


Thanks Peter!!!

This was just the information I was looking for!

John Patten


Date: Thu, 22 Apr 2010 23:39:17 -0800 (PST)
From: Peter Alcibiades <palcibiades-first at yahoo.co.uk>
Subject: Re: Record Audio in Rev on Linux OS?
To: use-revolution at lists.runrev.com
Message-ID: <1272008357927-2032844.post at n4.nabble.com>
Content-Type: text/plain; charset=us-ascii


Invoking the shell command is the easy part.  First, you open a  
terminal and
verify that the command or script you want to use works properly from  
the
terminal.  For example, if you are going to use krecord you would open a
terminal and do

     krec

followed by whatever options you want.

(this seems to be the command which opens the app now, seems to me it  
used
to be krecord but still.....)

Now you know that it works as expected in the shell, you can invoke it  
from
Rev:

     put shell("krec")   -- this will just open the application.

For instance, to execute the command you gave as a sample, from a  
button,
you would just do:

     on mouseUp
     put shell("arecord -d 10 -f cd -t wav -D copy foobar.wav")
     end mouseUp

This would then record the file in the user's home directory as  
foobar.wav.

You can execute any shell command like this.

You can also pipe the output of one shell command to the input of  
another
one, in a shell command, as in

     ls | gedit

this will have the effect of first listing the current directory  
contents,
then sending the result to gedit, in which the input will be opened.   
You
could use this to send a file, once recorded, to a player.  Or, if you  
have
lame installed, you could use it to convert the file to mp3 with
soundconverter.

Finally, you might need to execute commands one after the other, which  
you
can also do.  To do this, you put your script into a file, for example,
myscript.sh, have the first line be a so called 'shebang', make it
executable, and put in your commands one after the other.  Lets say you
wanted the file in the above example to go to the desktop:

     #! /usr/bin/env bash
     cd Desktop
     arecord -d 10 -f cd -t wav -D copy foobar.wav

Now you would do, from your button,

     put shell (myscript.sh)     -- the file would have to be made
executable.

The shell is a quite fully featured, if rather antique, programming
language, with what you might regard as a huge collection of macros and
utilities for all kinds of purposes.  Most of the stuff you would  
expect,
flow control, branching, error reporting etc.   There are lots of  
guides to
it on the net, but if you're in an academic environment the simplest  
might
be to find someone in IT who has scripting experience and have them  
write
it.  If you want to learn it yourself, there is a nice book, full of  
worked
examples, by Glen Smith:  Introduction to Shell Scripting.  Might be a  
bit
basic for an experienced programmer.

It is antique, but its ideal for this sort of thing, because of the  
ability
to invoke stuff like krec.  On Rev, because of the limitations of Rev on
Linux at the moment, its a lifesaver.

Peter


-- 
View this message in context: http://runtime-revolution.278305.n4.nabble.com/Record-Audio-in-Rev-on-Linux-OS-tp2016409p2032844.html
Sent from the Revolution - User mailing list archive at Nabble.com.


------------------------------



More information about the use-livecode mailing list