any tricks to make SHELL non blocking?

classic Classic list List threaded Threaded
34 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: [OT] any tricks to make SHELL non blocking?

J. Landman Gay via use-livecode
AAARRRGGGHHHHHHH!!!

Bob S


> On Feb 4, 2018, at 11:23 , J. Landman Gay via use-livecode <[hidden email]> wrote:
>
> On 2/4/18 12:13 PM, prothero--- via use-livecode wrote:
>> Totally ot,
>> My mother in law had an iron drain deteriorate, with roots and cracks all through it,
>
> Not totally off-topic. If you drop a large enough shell into a pipe it will be blocking.
>
> --
> Jacqueline Landman Gay


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: any tricks to make SHELL non blocking?

J. Landman Gay via use-livecode
In reply to this post by J. Landman Gay via use-livecode
On Sun, Feb 4, 2018 at 10:13 AM, prothero--- via use-livecode <
[hidden email]> wrote:

> Totally ot,
> My mother in law had an iron drain deteriorate, with roots and cracks all
> through it, and Roto Rooter was able to ream it and put in some kind of
> epoxy liner, so nothing had to be dug up.
>

We had thought, from the video, that the bottom half of the iron pipe had
disintegrated (and so did that plumber).

It turned out that, no, that was the beginning of a blockage that grew to
100%.

Petrified fat.

Given what we know from going through the shower floor (last tenant poured
concrete down the drain in spite), the pipes likely weren't at the proper
angle to drain (a retired pipe-fitter friend could tell the shower wasn't
angled right at a glance!).

(Our house was built during the mob's heyday in Las Vegas, late 60s).




--
Dr. Richard E. Hawkins, Esq.
(702) 508-8462
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: any tricks to make SHELL non blocking?

J. Landman Gay via use-livecode
On 02/05/2018 12:02 PM, Dr. Hawkins via use-livecode wrote:

> disintegrated (and so did that plumber).

!!!

--
  Mark Wieder
  [hidden email]

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: any tricks to make SHELL non blocking?

J. Landman Gay via use-livecode
On Mon, Feb 5, 2018 at 2:18 PM, Mark Wieder via use-livecode <
[hidden email]> wrote:

> On 02/05/2018 12:02 PM, Dr. Hawkins via use-livecode wrote:
>
> disintegrated (and so did that plumber).
>>
>
> !!!
>
>
*shrug*

So I'm a vengeful homeowner.

:)

--
Dr. Richard E. Hawkins, Esq.
(702) 508-8462
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: any tricks to make SHELL non blocking?

J. Landman Gay via use-livecode
seriously, back on topic...
on mac -- El Capitan
calling shell
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'*

this works fine, LC just doesn't return control until it's fully imported
the file off of the CD.
I just want to keep a simple counter going during the file import.

I've tried these variations below without success. It's true, I get screwed
by syntax and quotes all the time, but I still have not found why these
won't work. Sometimes these will copy the file, but does not release until
done.

./ffmpeg -i "/Volumes/Audio CD/1 Audio Track.aif" "/Volumes/20160518 KJAZ
ARCHIVE MASTER/JULY - JAN 2017/20180204 TEST1.wav &"

./ffmpeg -i "/Volumes/Audio CD/1 Audio Track.aif" "/Volumes/20160518 KJAZ
ARCHIVE MASTER/JULY - JAN 2017/20180204 TEST1.wav" &

(./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... you guys rock.

sqb







--
Stephen Barncard - Sebastopol Ca. USA -
mixstream.org

On Mon, Feb 5, 2018 at 2:43 PM, Dr. Hawkins via use-livecode <
[hidden email]> wrote:

> On Mon, Feb 5, 2018 at 2:18 PM, Mark Wieder via use-livecode <
> [hidden email]> wrote:
>
> > On 02/05/2018 12:02 PM, Dr. Hawkins via use-livecode wrote:
> >
> > disintegrated (and so did that plumber).
> >>
> >
> > !!!
> >
> >
> *shrug*
>
> So I'm a vengeful homeowner.
>
> :)
>
> --
> Dr. Richard E. Hawkins, Esq.
> (702) 508-8462
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: any tricks to make SHELL non blocking?

J. Landman Gay via use-livecode
Don't recall if anyone has already mentioned using open process  but..

But.. If you build your known working string ( ./ffmpeg -i '/Volumes/Audio
CD/1 Audio Track.aiff' '/Volumes/20160518 KJAZ
ARCHIVE MASTER/JULY - JAN 2017/20040315-2-JD0211b.wav') and put it in a
variable tCommand and then do..
open process tCommand for neither
does it do what you want?

On Mon, Feb 5, 2018 at 10:04 PM, Stephen Barncard via use-livecode <
[hidden email]> wrote:

> seriously, back on topic...
> on mac -- El Capitan
> calling shell
> 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'*
>
> this works fine, LC just doesn't return control until it's fully imported
> the file off of the CD.
> I just want to keep a simple counter going during the file import.
>
> I've tried these variations below without success. It's true, I get screwed
> by syntax and quotes all the time, but I still have not found why these
> won't work. Sometimes these will copy the file, but does not release until
> done.
>
> ./ffmpeg -i "/Volumes/Audio CD/1 Audio Track.aif" "/Volumes/20160518 KJAZ
> ARCHIVE MASTER/JULY - JAN 2017/20180204 TEST1.wav &"
>
> ./ffmpeg -i "/Volumes/Audio CD/1 Audio Track.aif" "/Volumes/20160518 KJAZ
> ARCHIVE MASTER/JULY - JAN 2017/20180204 TEST1.wav" &
>
> (./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... you guys rock.
>
> sqb
>
>
>
>
>
>
>
> --
> Stephen Barncard - Sebastopol Ca. USA -
> mixstream.org
>
> On Mon, Feb 5, 2018 at 2:43 PM, Dr. Hawkins via use-livecode <
> [hidden email]> wrote:
>
> > On Mon, Feb 5, 2018 at 2:18 PM, Mark Wieder via use-livecode <
> > [hidden email]> wrote:
> >
> > > On 02/05/2018 12:02 PM, Dr. Hawkins via use-livecode wrote:
> > >
> > > disintegrated (and so did that plumber).
> > >>
> > >
> > > !!!
> > >
> > >
> > *shrug*
> >
> > So I'm a vengeful homeowner.
> >
> > :)
> >
> > --
> > Dr. Richard E. Hawkins, Esq.
> > (702) 508-8462
> > _______________________________________________
> > use-livecode mailing list
> > [hidden email]
> > Please visit this url to subscribe, unsubscribe and manage your
> > subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
> >
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: any tricks to make SHELL non blocking?

J. Landman Gay via use-livecode
On Mon, Feb 5, 2018 at 9:46 PM, Mike Bonner via use-livecode <
[hidden email]> wrote:

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

double quotes cause evaluation (for shell variables?), back quote (`)
causes contents to execute.  You seem to be using ', which is a literal.

Oh, I see.

You have *SPACES* in file names.

This *ALWAYS* leads to suffering.

Quoting a filename does not make it ok; it's still multiple words. If you
want to keep such evil names, you'll have to escape those spaces with \
 (backslash).

A better idea is to get all the spaces out of filenames.  I only allow
letters, dot, and underscore.

You also have hyphens, which have meaning on some operating systems.

--
Dr. Richard E. Hawkins, Esq.
(702) 508-8462
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: any tricks to make SHELL non blocking?

J. Landman Gay via use-livecode
Mike Bonner:  I'll try the Open Process suggestion you made - again with
more syntax variations this time. thanks!

Dr Hawkins - I don't have control over the name of the CD source file..

1 Audio Track.aiff

the OS demuxes the data on the CD and gives them generic names.
surely there must be a way to encapsulate URL strings properly to use
spaces and hyphens.  Do I have to add the escapes manually using lookups
and exceptions?

the folder names are no big deal to fix, but I've got a library of hundreds
of shows where I already use hyphens and have been successfully imported..

Dr Hawkins:  when you say "escape spaces" do you mean something like

\%20

or

\[actual space char]

  ?

I only care about this working on Macs, by the way.
This is just an ugly thing that saves me time in a huge archive project.
The UI sucks, but it's all just for me.
This "app" I've created allows me to save keystrokes in the process of:

0. assign a name to the performance, type in a field (I avoid spaces but
there are hyphens - I could use underscores I guess but they look so ugly -
perhaps I can 'get away' with those on a mac.
1. taking a picture of the CD, cover and contents and saving as a file
 (using oss imagesnap and a webcam)
     (I would have used a flatbed scanner but I couldn't find a useable oss
executable and scanning and loading is slower )
2. importing the first CD file after it is inserted, converting it to WAV
from AIF, and saving it with with the chosen name. (using ffmpeg)
3. create a folder with the chosen names and put the like named files (
with .png and .wav suffixes ) in that folder. (using Livecode)

metadata (like song titles) could be put into a .txt file in that folder
later. I plan a bot that will send samples to a Grace Note like service to
harvest song titles.

My idea is that the file structure and meta ARE the database and a data
listing could be created from that structure 'just in time'. This is
important in an archive that is rapidly getting added to or changed (like
filenames !!) and makes more sense to me that having to enter and update a
separate database. The archive is limited enough in items that speed is not
an issue.

this has taken the process from taking three separate apps (including the
dreaded iTunes and Photobooth?? ) and dozens of clicks, cut and paste names
etc.) and lots of typing to a single entity where I only have to enter that
name ONCE. And iTunes import and convert took 10 minutes for a 60 minute
piece - whereas ffmpeg takes only 2:15.   I can do a turnaround within 4
minutes now.

thanks for the tip on quotes and backquotes.

but like I said, the commands do work when I don't try to  release control
to the calling script after the external executable is started.

The lack of being able to do this is NOT a show stopper. Livecode has been
able to let me create this monster kluge in very little development time
and it works.



--
Stephen Barncard - Sebastopol Ca. USA -
mixstream.org

On Tue, Feb 6, 2018 at 8:25 AM, Dr. Hawkins via use-livecode <
[hidden email]> wrote:

> On Mon, Feb 5, 2018 at 9:46 PM, Mike Bonner via use-livecode <
> [hidden email]> wrote:
>
> >
> > > (./ffmpeg -i '/Volumes/Audio CD/1 Audio Track.aiff' '/Volumes/20160518
> > KJAZ
> > > ARCHIVE MASTER/JULY - JAN 2017/20040315-2-JD0211b.wav' &)
> >
>
> double quotes cause evaluation (for shell variables?), back quote (`)
> causes contents to execute.  You seem to be using ', which is a literal.
>
> Oh, I see.
>
> You have *SPACES* in file names.
>
> This *ALWAYS* leads to suffering.
>
> Quoting a filename does not make it ok; it's still multiple words. If you
> want to keep such evil names, you'll have to escape those spaces with \
>  (backslash).
>
> A better idea is to get all the spaces out of filenames.  I only allow
> letters, dot, and underscore.
>
> You also have hyphens, which have meaning on some operating systems.
>
> --
> Dr. Richard E. Hawkins, Esq.
> (702) 508-8462
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: any tricks to make SHELL non blocking?

J. Landman Gay via use-livecode
On Tue, Feb 6, 2018 at 12:03 PM, Stephen Barncard via use-livecode <
[hidden email]> wrote:

> Mike Bonner:  I'll try the Open Process suggestion you made - again with
> more syntax variations this time. thanks!
>
> Dr Hawkins - I don't have control over the name of the CD source file..
>

You can change them.   once you have the name in filNam,

put filNam into newFilNam

replace space with "\ " in filNam

replace space with "_" in newFilNam

get shell ("mv filNam newFilNam")


or, just use newFilNam--but spaces in filenames are always going to hurt
and cause problem, not mater the source.

>
>
> Dr Hawkins:  when you say "escape spaces" do you mean something like
>
> \%20
>
ack, no!  that's html!


>
> or
>
> \[actual space char]
>

yes, this--it's not a regex, but the shell recognizes this an a couple of
others, some with different meanings than in a regex


--
Dr. Richard E. Hawkins, Esq.
(702) 508-8462
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: any tricks to make SHELL non blocking?

J. Landman Gay via use-livecode
In reply to this post by J. Landman Gay via use-livecode
On 02/06/2018 10:25 AM, Dr. Hawkins via use-livecode wrote:

> double quotes cause evaluation (for shell variables?), back quote (`)
> causes contents to execute.  You seem to be using ', which is a literal.
>
> You have*SPACES*  in file names.
>
> This*ALWAYS*  leads to suffering.
>
> Quoting a filename does not make it ok; it's still multiple words. If you
> want to keep such evil names, you'll have to escape those spaces with \
>   (backslash).

With all due respect, this is not all correct information. It is
perfectly valid to escape using single quotes (and double quotes) on the
command line and it works inside a LC shell function.

Just to save time, here are some sources for verification:

https://www.tech-otaku.com/mac/file-folder-paths-os-x-terminal/

http://wiki.bash-hackers.org/syntax/quoting (see "Weak quoting" and
"Strong quoting")

Warren

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: any tricks to make SHELL non blocking?

J. Landman Gay via use-livecode
In reply to this post by J. Landman Gay via use-livecode
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

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: any tricks to make SHELL non blocking?

J. Landman Gay via use-livecode
In reply to this post by J. Landman Gay via use-livecode
> Warren S. wrote:
> 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.

It is not quite clear what is meant with "Unix process" in the dictionary.

This is, at any rate, not the same as "Unix executable" in the sense of MacOS.
Probably a standard like
https://en.wikipedia.org/wiki/List_of_Unix_commands

ffmpeg isn't such a standard, but doesn't work with open process, others do.

I use "open process p0 for neither", where p0 is a variable of type
"<unix_executable> <args>", with success for several other unix executables.

Back to "shell":
You are obviously an expert with the shell/unix. It would be greatly appreciated
if you would share a general non-blocking shell command:
Non-blocking shells are often needed/wanted and you could write a command which
collects the advices from your last post. In the special case of ffmpeg it may
even be possible to redirect STDERR to a file that can be scanned while a large
job is running?


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: any tricks to make SHELL non blocking?

J. Landman Gay via use-livecode
On 02/06/2018 07:35 PM, hh via use-livecode wrote:
> You are obviously an expert with the shell/unix.


Nothing of the sort, I'm just sharing some information I have collected
from other sources and have found to work in this kind of situation :D

Warren

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: any tricks to make SHELL non blocking?

J. Landman Gay via use-livecode
In reply to this post by J. Landman Gay via use-livecode
On Tue, Feb 6, 2018 at 3:28 PM, Warren Samples via use-livecode <
[hidden email]> wrote:

>
>>
> With all due respect, this is not all correct information. It is perfectly
> valid to escape using single quotes (and double quotes) on the command line


hmm, for spaces, that seems to be correct.

But that just proves the point; spaces in filenames are evil :)

I learned unix on a cluster PDP-11 over three decades ago, and I'm still
off on this.

There are other things, however, notably environmental variables, that do
not get escaped in the weak quoting of double quotes.



> and it works inside a LC shell function.
>
> Just to save time, here are some sources for verification:
>
> https://www.tech-otaku.com/mac/file-folder-paths-os-x-terminal/
>
> http://wiki.bash-hackers.org/syntax/quoting (see "Weak quoting" and
> "Strong quoting"


careful;  OSX defaults to tcsh, not bash.


--
Dr. Richard E. Hawkins, Esq.
(702) 508-8462
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
12