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
|

any tricks to make SHELL non blocking?

Graham Samuel via use-livecode
Hi friends,

I have a command line utility which will process a generated file like:
...
get shell(q(tCommandLineUtility) && q(tGeneratedFile))
...

FYI:
function q tString
 return QUOTE & tString & QUOTE
end q


Any hints on how to make this NON blocking somehow?
I need a solution for Mac and Win.

Thanks for any hint.


Best

Klaus

--
Klaus Major
http://www.major-k.de
[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?

Graham Samuel via use-livecode
Run it in a different app that you communicate with via sockets? Or
maybe run that app as a process?

You said *any* hints, so... be careful what you ask for! :-)

Phil Davis



On 2/2/18 1:41 PM, Klaus major-k via use-livecode wrote:

> Hi friends,
>
> I have a command line utility which will process a generated file like:
> ...
> get shell(q(tCommandLineUtility) && q(tGeneratedFile))
> ...
>
> FYI:
> function q tString
>   return QUOTE & tString & QUOTE
> end q
>
>
> Any hints on how to make this NON blocking somehow?
> I need a solution for Mac and Win.
>
> Thanks for any hint.
>
>
> Best
>
> Klaus
>
> --
> Klaus Major
> http://www.major-k.de
> [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
>

--
Phil Davis


_______________________________________________
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?

Graham Samuel via use-livecode
In reply to this post by Graham Samuel via use-livecode
I don't think you can use shell as non-blocking. You could use 'open
process' to spawn your command line utility off as a subprocess which
would be non blocking, but that approach has its own over head thing to
work around


On 2/2/2018 4:41 PM, Klaus major-k via use-livecode wrote:

> Hi friends,
>
> I have a command line utility which will process a generated file like:
> ...
> get shell(q(tCommandLineUtility) && q(tGeneratedFile))
> ...
>
> FYI:
> function q tString
>  return QUOTE & tString & QUOTE
> end q
>
>
> Any hints on how to make this NON blocking somehow?
> I need a solution for Mac and Win.
>
> Thanks for any hint.
>
>
> Best
>
> Klaus
>
> --
> Klaus Major
> http://www.major-k.de
> [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
>


_______________________________________________
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?

Graham Samuel via use-livecode
Paul Dupuis wrote:

 > I don't think you can use shell as non-blocking. You could use 'open
 > process' to spawn your command line utility off as a subprocess which
 > would be non blocking, but that approach has its own over head thing
 > to work around

What additional overhead is incurred by running a process via "open
process" vs the shell function?

--
  Richard Gaskin
  Fourth World Systems


_______________________________________________
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?

Graham Samuel via use-livecode
In reply to this post by Graham Samuel via use-livecode
This is non-blocking:

put tCommandLineUtility && q(tGeneratedFile) into p0
open process p0 for neither -- no need to close that

Don't use quotes for the utility.
You have no feedback with that. That's the advantage of shell.

> Klaus M. wrote:
> Hi friends,
> I have a command line utility which will process a generated file like:
> ...
> get shell(q(tCommandLineUtility) && q(tGeneratedFile))
> ...
> FYI:
> function q tString
>  return QUOTE & tString & QUOTE
> end q
> Any hints on how to make this NON blocking somehow?
> I need a solution for Mac and Win.
> Thanks for any hint.

_______________________________________________
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?

Graham Samuel via use-livecode
In reply to this post by Graham Samuel via use-livecode
Hi Phil,

> Am 02.02.2018 um 23:30 schrieb Phil Davis via use-livecode <[hidden email]>:
>
> Run it in a different app that you communicate with via sockets? Or maybe run that app as a process?
> You said *any* hints, so... be careful what you ask for! :-)

yep, get it! :-D

> Phil Davis
>
> On 2/2/18 1:41 PM, Klaus major-k via use-livecode wrote:
>> Hi friends,
>> I have a command line utility which will process a generated file like:
>> ...
>> get shell(q(tCommandLineUtility) && q(tGeneratedFile))
>> ...
>> FYI:
>> function q tString
>>  return QUOTE & tString & QUOTE
>> end q
>>
>> Any hints on how to make this NON blocking somehow?
>> I need a solution for Mac and Win.
>>
>> Thanks for any hint.

Best

Klaus

--
Klaus Major
http://www.major-k.de
[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?

Graham Samuel via use-livecode
In reply to this post by Graham Samuel via use-livecode
Hello Hermann,

> Am 02.02.2018 um 23:53 schrieb hh via use-livecode <[hidden email]>:
>
> This is non-blocking:
>
> put tCommandLineUtility && q(tGeneratedFile) into p0
> open process p0 for neither -- no need to close that
>
> Don't use quotes for the utility.
> You have no feedback with that. That's the advantage of shell.

great, thank you, will try this tomorrow!

>> Klaus M. wrote:
>> Hi friends,
>> I have a command line utility which will process a generated file like:
>> ...
>> get shell(q(tCommandLineUtility) && q(tGeneratedFile))
>> ...
>> FYI:
>> function q tString
>> return QUOTE & tString & QUOTE
>> end q
>> Any hints on how to make this NON blocking somehow?
>> I need a solution for Mac and Win.
>> Thanks for any hint.

Best

Klaus

--
Klaus Major
http://www.major-k.de
[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?

Graham Samuel via use-livecode
In reply to this post by Graham Samuel via use-livecode
Hi Hermann,

> Am 02.02.2018 um 23:53 schrieb hh via use-livecode <[hidden email]>:
>
> This is non-blocking:
>
> put tCommandLineUtility && q(tGeneratedFile) into p0
> open process p0 for neither -- no need to close that
>
> Don't use quotes for the utility.
> You have no feedback with that. That's the advantage of shell.

just tested on my Mac, no luck.
And "the result" = EMPTY

>> Klaus M. wrote:
>> Hi friends,
>> I have a command line utility which will process a generated file like:
>> ...
>> get shell(q(tCommandLineUtility) && q(tGeneratedFile))
>> ...
>> FYI:
>> function q tString
>> return QUOTE & tString & QUOTE
>> end q
>> Any hints on how to make this NON blocking somehow?
>> I need a solution for Mac and Win.
>> Thanks for any hint.

Best

Klaus

--
Klaus Major
http://www.major-k.de
[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?

Graham Samuel via use-livecode
Hi Hermann,

> Am 03.02.2018 um 00:02 schrieb Klaus major-k via use-livecode <[hidden email]>:
>
> Hi Hermann,
>
>> Am 02.02.2018 um 23:53 schrieb hh via use-livecode <[hidden email]>:
>>
>> This is non-blocking:
>>
>> put tCommandLineUtility && q(tGeneratedFile) into p0
>> open process p0 for neither -- no need to close that
>>
>> Don't use quotes for the utility.
>> You have no feedback with that. That's the advantage of shell.
>
> just tested on my Mac, no luck.
> And "the result" = EMPTY

sorry, I had a typo in my script, it WORKS, thanks a lot!


Best

Klaus
--
Klaus Major
http://www.major-k.de
[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?

Graham Samuel via use-livecode
In reply to this post by Graham Samuel via use-livecode
On 2/2/2018 5:42 PM, Richard Gaskin via use-livecode wrote:

> Paul Dupuis wrote:
>
> > I don't think you can use shell as non-blocking. You could use 'open
> > process' to spawn your command line utility off as a subprocess which
> > would be non blocking, but that approach has its own over head thing
> > to work around
>
> What additional overhead is incurred by running a process via "open
> process" vs the shell function?
>
Correction, I wasn't speaking of 'overhead' as CPU overhead, but as
other things you may need to do as a developer. For example, shell()
nicely runs the app specified and returns any return value, where as
with 'open process' you need to also read from the process to get
returned data, close the process. Any helper app you install that you
call via open process (i.e. some app that is not already part of the OS
or installed software), you really need to code sign (a good practice
anyway) otherwise, assorted 3rd party security tools (mostly on Windows
like McAfee or Norton) are likely to interfere with your launching of
the app via open process by treating it as suspicious activity.

There are probably a few other detail I have forgotten as I wrote this.
We just went through this for a couple of HyperRESEARCH (our app) helper
apps (also LC standalones) that 4.0 of HyperRESEARCH communicates with.

FYI we found that interapp communication via sockets is more reliable
cross-platform that via interprocess communication, but at some real
world customer sites, security setting can prohibit socket communication
even to the same computer where as IPC still works, so an app that need
to be really really robust for real world installs may wish to include
code for both and swap from one to the other if one means of
communication fails.

-- Paul


_______________________________________________
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?

Graham Samuel via use-livecode
In reply to this post by Graham Samuel via use-livecode
> Klaus wrote:
> ... it WORKS, thanks a lot!

How could you doubt that!?  :-(
I never post things that I didn't test thoroughly, learned that from 'bn'.
In this case I looked into the script of my next Mac/Win/Linux/Raspi-stack "timeLapseCamera" which runs since four days without problems.
I have it running with up to 4 cheap USB-webcams at different repeat rates.
There is no blocking with my tests even if they fire all at the same full
second.




_______________________________________________
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?

Graham Samuel via use-livecode
Hi Hermann,

> Am 03.02.2018 um 00:35 schrieb hh via use-livecode <[hidden email]>:
>
>> Klaus wrote:
>> ... it WORKS, thanks a lot!
>
> How could you doubt that!?  :-(

sorry, really didn't mean it personally! ;-)

> I never post things that I didn't test thoroughly, learned that from 'bn'.
> In this case I looked into the script of my next Mac/Win/Linux/Raspi-stack "timeLapseCamera" which runs since four days without problems.
> I have it running with up to 4 cheap USB-webcams at different repeat rates.
> There is no blocking with my tests even if they fire all at the same full
> second.

Way cool, dude!
Voll krass, Alter! :-)


Best

Klaus

--
Klaus Major
http://www.major-k.de
[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?

Graham Samuel via use-livecode
In reply to this post by Graham Samuel via use-livecode
> Way cool, dude!
> Voll krass, Alter! :-)

Yes. I once was also a young man with curly hair -- like you. are now ...

_______________________________________________
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?

Graham Samuel via use-livecode
In reply to this post by Graham Samuel via use-livecode
On Fri, Feb 2, 2018 at 1:41 PM, Klaus major-k via use-livecode <
[hidden email]> wrote:

>
> Any hints on how to make this NON blocking somehow?
> I need a solution for Mac and Win.
>
> I don''t know  about darkside machines, but on  \begin{condescending
snark} mac and other real operating systems \end{snark}, you can launch
commands into the background by suffixing  with  &

You may (or may not; it was years ago) need to enclose the command  in
parenthesis, which makes the whole parenthetical a block.  You might also
need to redirect output.

 so

    shell ( "(domycommand > myoutput &)"  )

or something like that, and come back later to check myoutput



--
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?

Graham Samuel via use-livecode
In reply to this post by Graham Samuel via use-livecode
Paul Dupuis wrote:

 > FYI we found that interapp communication via sockets is more reliable
 > cross-platform that via interprocess communication, but at some real
 > world customer sites, security setting can prohibit socket
 > communication even to the same computer where as IPC still works, so
 > an app that need to be really really robust for real world installs
 > may wish to include code for both and swap from one to the other if
 > one means of communication fails.

If everyone would just get over themselves and start using Linux we
could all enjoy named pipes. :)

But seriously, do you have a list of circumstances that prevent sockets
on loopback?

Personally, I'm inclined to consider it a bug if any software prevents
IPC via loopback sockets, but there may be a good reason worth learning.
  And even if the reasoning turns out not to be good, it's useful to
know about limitations imposed on otherwise-reliable mechanisms.

--
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  [hidden email]                http://www.FourthWorld.com

_______________________________________________
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?

Graham Samuel via use-livecode
On 02/03/2018 02:31 PM, Richard Gaskin via use-livecode wrote:

> If everyone would just get over themselves and start using Linux we
> could all enjoy named pipes. :)

After working on our kitchen plumbing for the last few days, I've got a
few choice names for pipes.

--
  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?

Graham Samuel via use-livecode
The Husband loves plumbing, it gives him the inspiration to learn all kinds
of new colorful words. He puts it off as long as possible to savor the
anticipation.

--
Jacqueline Landman Gay         |     [hidden email]
HyperActive Software           |     http://www.hyperactivesw.com



On February 3, 2018 5:35:00 PM Mark Wieder via use-livecode
<[hidden email]> wrote:

> On 02/03/2018 02:31 PM, Richard Gaskin via use-livecode wrote:
>
>> If everyone would just get over themselves and start using Linux we
>> could all enjoy named pipes. :)
>
> After working on our kitchen plumbing for the last few days, I've got a
> few choice names for pipes.
>
> --
>   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



_______________________________________________
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?

Graham Samuel via use-livecode
On Sat, Feb 3, 2018 at 4:51 PM, J. Landman Gay via use-livecode <
[hidden email]> wrote:

> The Husband loves plumbing, it gives him the inspiration to learn all
> kinds of new colorful words. He puts it off as long as possible to savor
> the anticipation
>


There's nothing like the joy of going weeks of carting the water from the
kitchen sink down the hall, as it drains into a five gallon bucket, because
the sewer line is 100% blocked a couple of feet under the concrete slab
under the the living room.

Not even the thrill of the redneck connection of a garden hose to the
washing machine to run down the driveway, or even the 2'x22' trench three
feet deep across the room that you get to step over for a couple of days
 as the work is done and you wait for inspectors.

On the bright side, we replaced with ABS rather than cast iron, so it
should last a touch longer, and even the same 50 years means i wont be here
when it happens . . .

--
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?

Graham Samuel via use-livecode
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.
Bill

William Prothero
http://es.earthednet.org

> On Feb 4, 2018, at 7:53 AM, Dr. Hawkins via use-livecode <[hidden email]> wrote:
>
> On Sat, Feb 3, 2018 at 4:51 PM, J. Landman Gay via use-livecode <
> [hidden email]> wrote:
>
>> The Husband loves plumbing, it gives him the inspiration to learn all
>> kinds of new colorful words. He puts it off as long as possible to savor
>> the anticipation
>>
>
>
> There's nothing like the joy of going weeks of carting the water from the
> kitchen sink down the hall, as it drains into a five gallon bucket, because
> the sewer line is 100% blocked a couple of feet under the concrete slab
> under the the living room.
>
> Not even the thrill of the redneck connection of a garden hose to the
> washing machine to run down the driveway, or even the 2'x22' trench three
> feet deep across the room that you get to step over for a couple of days
> as the work is done and you wait for inspectors.
>
> On the bright side, we replaced with ABS rather than cast iron, so it
> should last a touch longer, and even the same 50 years means i wont be here
> when it happens . . .
>
> --
> 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
|

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

Graham Samuel via use-livecode
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         |     [hidden email]
HyperActive Software           |     http://www.hyperactivesw.com

_______________________________________________
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