TerminalView

Post

Posted
Rating:
#1 (In Topic #1466)
Regular
rj71 is in the usergroup ‘Regular’
 Hi All,
I finallly found some time to revisit something I was working on last year: Running bash and python scripts inside a terminalview. Thanks to some help from Bruce Steers, I have a simple working app. Nothing fancy but I am using it to experiment with terminalview. One scenario is a button on the form that will launch a specific script. If I hit the button again and the script is already running I get a "terminal already in use" error. Looking at the wiki, I don't see how I would check if the terminal is being used. I guess I could kill the script and restart but I'm not sure if that's a good idea. Can someone point me in the right direction?
Online now: No Back to the top

Post

Posted
Rating:
#2
Banned
use the Process of the Shell or Exec commmand.
/comp/gb/process - Gambas Documentation

eg..

Code (gambas)

  1.  
  2. Public Sub RunCommand()
  3.  
  4.  hProc = TerminalView1.Shell("the-command")
  5.  
  6.  
  7.  

Then Process.State can be checked

Code (gambas)

  1. If hProc.State = Process.Running Then
  2.   Message("Process already running")
  3.  
  4.  

Note if you are running bash you cannot tell if the bash shell is running a process.  from the TerminalViews perspective bash is the process that is always running until you exit.
It's only possible if the terminal is running commands directly and not using a bash shell.
Online now: No Back to the top

Post

Posted
Rating:
#3
Regular
rj71 is in the usergroup ‘Regular’

BruceSteers said

use the Process of the Shell or Exec commmand.
/comp/gb/process - Gambas Documentation

eg..

Code (gambas)

  1.  
  2. Public Sub RunCommand()
  3.  
  4.  hProc = TerminalView1.Shell("the-command")
  5.  
  6.  
  7.  

Then Process.State can be checked

Code (gambas)

  1. If hProc.State = Process.Running Then
  2.   Message("Process already running")
  3.  
  4.  

Note if you are running bash you cannot tell if the bash shell is running a process.  from the TerminalViews perspective bash is the process that is always running until you exit.
It's only possible if the terminal is running commands directly and not using a bash shell.

Thanks Bruce. I'll try this with the terminalview snippet you gave me last year.
Online now: No Back to the top
1 guest and 0 members have just viewed this.