Page 1 of 1
Shell - continuous output?
Posted: Tue Feb 17, 2015 10:47 pm
by trenatos
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?
Re: Shell - continuous output?
Posted: Fri Feb 20, 2015 2:16 am
by trenatos
It seems that open process might do what I need, building a small frame and then testing.
Re: Shell - continuous output?
Posted: Sat Feb 21, 2015 12:34 am
by trenatos
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?
Re: Shell - continuous output?
Posted: Sat Feb 21, 2015 12:45 am
by WaltBrown
Did you try:
"read from process pProcess until EOF"
to see if its waiting for a linefeed?
Walt
Re: Shell - continuous output?
Posted: Sat Feb 21, 2015 12:51 am
by trenatos
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.
Re: Shell - continuous output?
Posted: Sat Feb 21, 2015 1:02 am
by trenatos
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.
Re: Shell - continuous output?
Posted: Sat Feb 21, 2015 1:18 am
by trenatos
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
Re: Shell - continuous output?
Posted: Sat Feb 21, 2015 2:03 am
by trenatos
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.
Re: Shell - continuous output?
Posted: Wed Nov 04, 2015 4:54 am
by pdxkurt
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.
Re: Shell - continuous output?
Posted: Tue Dec 22, 2015 5:09 am
by WaltBrown
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
Re: Shell - continuous output?
Posted: Thu Apr 07, 2016 1:39 am
by trenatos
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).