Shell - continuous output?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
trenatos
Posts: 189
Joined: Wed Jul 03, 2013 6:46 am
Location: Virginia, USA
Contact:

Shell - continuous output?

Post by trenatos » Tue Feb 17, 2015 10:47 pm

I have an awesome idea, but it would require running shell commands and continuously grabbing/displaying the output.

All I can find reference to is about running a command and returning the output, is it possible to run continuously?
Marcus

trenatos
Posts: 189
Joined: Wed Jul 03, 2013 6:46 am
Location: Virginia, USA
Contact:

Re: Shell - continuous output?

Post by trenatos » Fri Feb 20, 2015 2:16 am

It seems that open process might do what I need, building a small frame and then testing.
Marcus

trenatos
Posts: 189
Joined: Wed Jul 03, 2013 6:46 am
Location: Virginia, USA
Contact:

Re: Shell - continuous output?

Post by trenatos » Sat Feb 21, 2015 12:34 am

I have partial success!

Ok, so I can open a process and read from it, but I'm getting UI locks and not sure how to get around that.

Here's what I'm using right now:

Code: Select all

command monSlave pProcess
   if runTheThing is true then
      read from process pProcess until linefeed
      put it after field "console"
      send "monSlave pProcess" to me in 50 milliseconds
   else
      write "^c" to process pProcess
      put CR & "Server stopped" after field "console"
   end if
end monSlave
I have a button that sets the runTheThing to false, to shut the process off, but with the GUI locking up I can't press the button.

If I press the button, nothing happens, if I then open the Task Manager and manually close the program, everything continues AND I see the "server stopped" message.

It seems that the button is recorded as pressed, but still having GUI lock.

Any ideas?
Marcus

WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm
Location: NE USA

Re: Shell - continuous output?

Post by WaltBrown » Sat Feb 21, 2015 12:45 am

Did you try:
"read from process pProcess until EOF"
to see if its waiting for a linefeed?
Walt
Walt Brown
Omnis traductor traditor

trenatos
Posts: 189
Joined: Wed Jul 03, 2013 6:46 am
Location: Virginia, USA
Contact:

Re: Shell - continuous output?

Post by trenatos » Sat Feb 21, 2015 12:51 am

Set to EOF I get nothing read, still locks up but nothing displayed.

I'm running a batch file which starts a java process, so I need to continuously read the window.
Marcus

trenatos
Posts: 189
Joined: Wed Jul 03, 2013 6:46 am
Location: Virginia, USA
Contact:

Re: Shell - continuous output?

Post by trenatos » Sat Feb 21, 2015 1:02 am

More testing.

It seems the locking is not while reading or outputting on screen, it happens BETWEEN. Which makes me think that it has to do with the "read from process pProcess for 1", if there isn't anything to read, it sits there waiting, locking up the GUI, so I'm going to try and see if I can make a check, if it is not empty, or whatever the check will actually be.
Marcus

trenatos
Posts: 189
Joined: Wed Jul 03, 2013 6:46 am
Location: Virginia, USA
Contact:

Re: Shell - continuous output?

Post by trenatos » Sat Feb 21, 2015 1:18 am

Ok, so more success!

(Not sure if anyone is following this, but I'm amused anyway)

By turning it into read from process pProcess until empty, I'm now getting continuous output, now it's a matter of sending control characters so I can send a ctrl-c
Marcus

trenatos
Posts: 189
Joined: Wed Jul 03, 2013 6:46 am
Location: Virginia, USA
Contact:

Re: Shell - continuous output?

Post by trenatos » Sat Feb 21, 2015 2:03 am

Newest issue is that I'm not having any luck sending ctrl-c to the process.

I do have the process opened to update, so it should accept read and write.
Marcus

pdxkurt
Posts: 1
Joined: Sat Dec 13, 2014 1:01 am

Re: Shell - continuous output?

Post by pdxkurt » Wed Nov 04, 2015 4:54 am

I would like to accomplish this same thing. Do you mind sharing what you've got so far? I'm trying to launch a shell that runs an executable with continuous output and pass a ctrl+c to it to stop when I push the stop button.

WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm
Location: NE USA

Re: Shell - continuous output?

Post by WaltBrown » Tue Dec 22, 2015 5:09 am

Trenatos,
Just a thought, does opening the process for text or binary update affect the ability to get a Ctrl-C? And did you try close process instead?
Walt
Walt Brown
Omnis traductor traditor

trenatos
Posts: 189
Joined: Wed Jul 03, 2013 6:46 am
Location: Virginia, USA
Contact:

Re: Shell - continuous output?

Post by trenatos » Thu Apr 07, 2016 1:39 am

I don't remember if I tried that.

I gave up on implementing this in LiveCode, it was easier to do in Lazarus (Object Pascal).
Marcus

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”