any tricks to make SHELL non blocking?

Warren Samples warren at warrensweb.us
Tue Feb 6 18:53:56 EST 2018


On 02/05/2018 11:04 PM, Stephen Barncard via use-livecode wrote:
> I have this open sourced app
> 
> ffmpeg
> 
> and I need to copy the first file from a CD, convert it to a wav file, name
> it, and save it to a file on a hard drive.
> (the executable is located in the same folder as the stack, hence the ./ )
> so my generated command used with the shell command is:
> 
> *./ffmpeg -i '/Volumes/Audio CD/1 Audio Track.aiff' '/Volumes/20160518 KJAZ
> ARCHIVE MASTER/JULY - JAN 2017/20040315-2-JD0211b.wav'
> 
> thanks for any suggestions...

The dictionary says: "On OS X systems, you can use the open process 
command to start up an application, but not a Unix process. To work with 
a Unix process, use the shell func instead." That makes me wonder if you 
can only use shell() with ffmpeg.

Did you try the suggestions from the other thread? Did they not do what 
you needed?

get shell ("nohup mycommand --some-params 'can use single quotes to 
escape if necessary' &")

here the command is prefaced with 'nohup' and a space and is closed
with a space and &


There are several variations for redirecting to /dev/null which also 
work to make the shell() non-blocking. Here's an example:

get shell ("mycommand --some-params 'can use single quotes to escape if 
necessary' </dev/null &>/dev/null &")


Using your example given here, they might look like this (linebreaks may 
not be correct due to email fun):

get shell("nohup ./ffmpeg -i '/Volumes/Audio CD/1 Audio Track.aiff' 
'/Volumes/20160518 KJAZ ARCHIVE MASTER/JULY - JAN 
2017/20040315-2-JD0211b.wav' &")

OR

get shell("./ffmpeg -i '/Volumes/Audio CD/1 Audio Track.aiff' 
'/Volumes/20160518 KJAZ ARCHIVE MASTER/JULY - JAN 
2017/20040315-2-JD0211b.wav' </dev/null &>/dev/null &")

The method using 'nohup' *might* cause a problem due to not finding 
ffmpeg at its path relative to your LiveCode app. If it fails, that 
would be the first thing to troubleshoot.

Good luck!

Warren




More information about the use-livecode mailing list