[Gambas-user] Stopping a CLI program

John Rose john.aaron.rose at ...626...
Tue Dec 10 14:49:38 CET 2013


Tobias,
I just realised that a post that I made on the 'Line continuation' 
thread is better in this thread. The details are:
I liked your ideas of:
Dim aExec As String[]
Dim sRes As String
aExec = ["cat", "/proc/meminfo"]
' Use aExec.Add() to add more arguments
Exec aExec To sRes

and (thread 'Stopping a CLI program):
Print #hFfmpeg, "q"
if you opened it For Output...

Currently I have:
Private hffmpeg as Process
Private sOutput As String
...
Dim aExec As String
...
aExec = ["ffmpeg"]
aExec.Add("-f x11grab")
aExec.Add("-s " & iScreenWidth & "x" & iScreenHeight)
aExec.Add("-i :0.0+" & iScreenLeft & "," & iScreenTop & "+nomouse")
aExec.Add("-f pulse")
aExec.Add("-i " & "alsa_output.pci-0000_00_1b.0.analog-stereo.monitor")
aExec.Add("-f " & sFileFormat)
aExec.Add("-vcodec" & svcodec)
aExec.Add("-r 25")
aExec.Add("-vb 1024k")
aExec.Add("-acodec" & sacodec)
aExec.Add("-ac 2")
aExec.Add("-ab 128k")
aExec.Add("-async 1")
aExec.Add("-threads " & bThreads)
aExec.Add("-y")
aExec.Add(sVideoPath)
hffmpeg = Exec aExec Wait For Read As "Messages"
...
Public Sub Messages_Read()
   Dim sLine As String
   Read #Last, sLine, -256
   sOutput &= sLine
End
Public Sub Messages_Kill()
   Print sOutput
End
...

Ideally, I'd like to add "Write" to the Exec line (as it seems to me that it won't go wrong if ffmpeg 'corrupts' the output file in comparison to using"hffmpeg.Kill()") , so that I can use (in a Stop button's click event):
Print #hffmpeg, "q"

However, I can't get the syntax right. I've tried 'Write' after 'For', 'Write' after 'Messages', 'For Write' between 'aExec' & 'For'. Is it possible to do this?

I don't understand the explanation of using Input instead of Read & 
Output instead of Write (i.e. "If you use the *INPUT* and *OUTPUT* 
keywords instead of *READ* and *WRITE*, then the process is executed 
inside a virtual terminal. The process will think running inside a true 
terminal.virtual terminal."). What are the implications of this, e.g. 
for my app?

-- 
Regards,
John




More information about the User mailing list