Viewing bash/php scripts in real time

Post your Gambas programming questions here.
User avatar
BruceSteers
Posts: 1624
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Viewing bash/php scripts in real time

Post by BruceSteers »

Another option could be to use a TerminalView not a TextArea you could then just run the script in the terminalview and see the normal terminal output.


Dim p as Process
p = TerminalView1.Shell("my/command")

While p.state = Process.Running
  Wait 0.1
Wend

If at first you don't succeed , try doing something differently.
BruceS
rj71
Posts: 41
Joined: Thursday 13th April 2023 6:39pm
Location: Vancouver WA

Re: Viewing bash/php scripts in real time

Post by rj71 »

BruceSteers wrote: Saturday 25th May 2024 12:45am Another option could be to use a TerminalView not a TextArea you could then just run the script in the terminalview and see the normal terminal output.


Dim p as Process
p = TerminalView1.Shell("my/command")

While p.state = Process.Running
  Wait 0.1
Wend

I'll play with terminal view and see if that works. Thanks Bruce!
rj71
Posts: 41
Joined: Thursday 13th April 2023 6:39pm
Location: Vancouver WA

Re: Viewing bash/php scripts in real time

Post by rj71 »

rj71 wrote: Saturday 25th May 2024 3:21pm
BruceSteers wrote: Saturday 25th May 2024 12:45am Another option could be to use a TerminalView not a TextArea you could then just run the script in the terminalview and see the normal terminal output.


Dim p as Process
p = TerminalView1.Shell("my/command")

While p.state = Process.Running
  Wait 0.1
Wend

I'll play with terminal view and see if that works. Thanks Bruce!
Hey Bruce, I like the terminalview and have made some changes to my back end scripts to make this work. Just one small problem: with longer running scripts, the terminalview eventually stops scrolling down and I can't tell if the script has finished without scrolling down manually. Is there a way to auto scroll to the bottom until the script finishes?
rj71
Posts: 41
Joined: Thursday 13th April 2023 6:39pm
Location: Vancouver WA

Re: Viewing bash/php scripts in real time

Post by rj71 »

Ah, I see the .ensurevisible now. Sweet!
User avatar
BruceSteers
Posts: 1624
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Viewing bash/php scripts in real time

Post by BruceSteers »

rj71 wrote: Saturday 25th May 2024 10:10pm
rj71 wrote: Saturday 25th May 2024 3:21pm
BruceSteers wrote: Saturday 25th May 2024 12:45am Another option could be to use a TerminalView not a TextArea you could then just run the script in the terminalview and see the normal terminal output.


Dim p as Process
p = TerminalView1.Shell("my/command")

While p.state = Process.Running
  Wait 0.1
Wend

I'll play with terminal view and see if that works. Thanks Bruce!
Hey Bruce, I like the terminalview and have made some changes to my back end scripts to make this work. Just one small problem: with longer running scripts, the terminalview eventually stops scrolling down and I can't tell if the script has finished without scrolling down manually. Is there a way to auto scroll to the bottom until the script finishes?
You got it, EnsureVisible :)

I found the same with TerminalView, mostly it's fine but occasionally it misses a scroll and then stops scrolling with the output.

I do something like this...

Public hProc As Process
Public hObs As Observer

Public Sub RunCommand(sCommand)

  hProc = TerminalView1.Shell(sCommand)
  hObs = New Observer(hProc) As "PROC"  ' Observe hProc events as PROC_EventName

End

Public Sub PROC_Read()   ' Trigger EnsureVisible on each Read event.

  TerminalView1.EnsureVisible()

End

' Detect when the command process ends and kill the event observer.
' PS. TerminalView1_Kill() does the same for this but we have a process event observer so I'll use that.
Public Sub PROC_Kill()

  hObs = Null

End
If at first you don't succeed , try doing something differently.
BruceS
rj71
Posts: 41
Joined: Thursday 13th April 2023 6:39pm
Location: Vancouver WA

Re: Viewing bash/php scripts in real time

Post by rj71 »

BruceSteers wrote: Sunday 26th May 2024 9:01am
rj71 wrote: Saturday 25th May 2024 10:10pm
rj71 wrote: Saturday 25th May 2024 3:21pm

I'll play with terminal view and see if that works. Thanks Bruce!
Hey Bruce, I like the terminalview and have made some changes to my back end scripts to make this work. Just one small problem: with longer running scripts, the terminalview eventually stops scrolling down and I can't tell if the script has finished without scrolling down manually. Is there a way to auto scroll to the bottom until the script finishes?
You got it, EnsureVisible :)

I found the same with TerminalView, mostly it's fine but occasionally it misses a scroll and then stops scrolling with the output.

I do something like this...

Public hProc As Process
Public hObs As Observer

Public Sub RunCommand(sCommand)

  hProc = TerminalView1.Shell(sCommand)
  hObs = New Observer(hProc) As "PROC"  ' Observe hProc events as PROC_EventName

End

Public Sub PROC_Read()   ' Trigger EnsureVisible on each Read event.

  TerminalView1.EnsureVisible()

End

' Detect when the command process ends and kill the event observer.
' PS. TerminalView1_Kill() does the same for this but we have a process event observer so I'll use that.
Public Sub PROC_Kill()

  hObs = Null

End
Thanks Bruce. I'll try this bit of code because I did a test this morning and the terminalview stopped auto scrolling down on a very long running script. I'll take a look at it tomorrow because it's Indy 500 day and I got some meats to grill and some racing to watch :D
rj71
Posts: 41
Joined: Thursday 13th April 2023 6:39pm
Location: Vancouver WA

Re: Viewing bash/php scripts in real time

Post by rj71 »

So I tried the code on a really long running script last night. The terminal view at some point stopped scrolling and even looked like it stop responding. I wasn't watching it so I don't know exactly how long the script ran before this happened. Not much I can do about the script, its just something that will take a long time to complete, so I guess its back to the drawing board for this project.
Post Reply