[Gambas-user] I need your help with Processes
Jussi Lahtinen
jussi.lahtinen at ...626...
Fri Feb 3 17:34:08 CET 2012
Hmmm... seem like you need to wait for the execution of the commands.
Try:
Public Sub Main()
> Dim fajl As File
> Dim tovabb As Boolean
> Dim i As Integer
> $hProcess = Exec ["bash", "--noediting"] For Input Output As "Process"
> tovabb = Run_command("ftp")
> tovabb = Run_command("open")
> tovabb = Run_command("ftp.mysite.com")
> tovabb = Run_command("myusername")
> tovabb = Run_command("mypassword")
> tovabb = Run_command("ls ./public_html -R")
>
Wait 1
Or implement more intelligent method to wait something to appear to read
event.
This isn't necessary:
> fajl = Open User.Home & "/Csabax.txt" For Create
> Close (fajl)
>
Instead use this:
fajl = Open User.Home & "/Csabax.txt" For Write Create
> For i = 0 To answers.Max
> Print #fajl, answers[i]
> Next
> Close (fajl)
>
This kills the process before commands are executed:
$hProcess.Kill
>
Instead of this:
> Public Sub Process_Read()
> Dim sStr As String
> Read #$hProcess, sStr, -256
> $sText = sStr
> answers.Add($sText)
> End
>
Use this:
Public Sub Process_Read()
Dim sStr As String
Read #$hProcess, sStr, -256
answers.Add(sStr)
End
Because otherwise, you can lose message written to $sText in error event.
Instead of this:
Public Sub Process_Error(sStr As String)
>
> $sText = $sText & sStr
>
> End
>
>
Use this:
Public Sub Process_Error(sStr As String)
answers.Add(sStr)
End
Hope this helps.
Jussi
More information about the User
mailing list