[Gambas-user] I need your help with Processes

M. Cs. mohareve at ...626...
Fri Feb 3 12:14:43 CET 2012


Public $hProcess As Process
Private $sText As String
Private answers As New String[]

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")
  fajl = Open User.Home & "/Csabax.txt" For Create
  Close (fajl)
  fajl = Open User.Home & "/Csabax.txt" For Write
  For i = 0 To answers.Max
    Print #fajl, answers[i]
  Next
  Close (fajl)
  $hProcess.Kill
  End

Public Sub Process_Read()
  Dim sStr As String
  Read #$hProcess, sStr, -256
  $sText = sStr
  answers.Add($sText)

End


Public Sub Process_Error(sStr As String)

  $sText = $sText & sStr

End

Public Sub Run_command(cmd As String) As Boolean
  Dim sLig As String
  sLig = cmd & gb.NewLine
  sLig = Conv$(sLig, Desktop.Charset, System.Charset)
  Print #$hProcess, sLig
  Return True
End

Private Function Normalize(sStr As String) As String
  Dim sNorm As String
  Dim iInd As Integer
  Dim iCar As Integer
  Dim bEsc As Boolean

  sNorm = sStr

  If System.Charset = Desktop.Charset Then
    Return sNorm
  Else
    Return Conv$(sNorm, System.Charset, Desktop.Charset)
  Endif

End


This is what I have stolen from the Console example. What I want is to
have a FTP site's content listed and stored in a local text file or in
variable for further processing. The problem is that this module
returns nothing.
How could I simulate the behaviour of a real console with predefined
myuser, mypassword and ftp address.
The same thing works with Console example, but I don't need a form or
anything else, just the result of "ls ./public_html -R" at the end.
Main() is called from other part of the program.

Thanks!

Csaba




More information about the User mailing list