[Gambas-user] I need your help with Processes

M. Cs. mohareve at ...626...
Fri Feb 3 20:31:27 CET 2012


Success!
I'm going to share it with you:

Public $hProcess As Process
Private $sText As String
Public Sub Main()
 Dim fajl As File
 Dim i As Integer
  $hProcess = Exec ["ftp", "ftp.mysite.com"] For Input Output As "Process"
  Run_command("cd ./public_html")
  Repeat
    Wait 0.1
  Until InStr($sText, "OK. Current directory") > 0
  $sText = ""
  Run_command("ls -lR")
  Repeat
    Wait 0.1
  Until InStr($sText, "matches total") > 0
  fajl = Open User.Home & "/Csabax.txt" For Write Create
     Print #fajl, $sText
   Close (fajl)
   $sText = ""
   Run_command("quit")
  '$hProcess.Kill
  End

Public Sub Process_Read()
  Dim sStr As String
  Read #$hProcess, sStr, -256
 $sText = $sText & sStr
 End
Public Sub Run_command(cmd As String)
  Dim sLig As String
  sLig = cmd & gb.NewLine
  sLig = Conv$(sLig, Desktop.Charset, System.Charset)
  Print #$hProcess, sLig
End

2012/2/3, M. Cs. <mohareve at ...626...>:
> I've managed to decrease the problem. I can create a ~/.netrc and I
> can place all the required data into it. So I'm able to reach the ftp
> server with
> Run_command("ftp ftp.mysite.com") , and I'm in.
> But how can I execute something inside that very same process?
> I don't understand that bubbling conception of Processes!
> If I would tell SHELL "ls ./public_home -R" it would open another
> virtual terminal, isn't?
> What would $hProcess=Exec["ls","./public_html","-R"] for Read do?
> I need some solid things!
>
> 2012/2/3, Jussi Lahtinen <jussi.lahtinen at ...626...>:
>>> Repeat
>>>    wait 1
>>> Until checker=TRUE
>>> checker=FALSE
>>> After every Run_command()
>>>
>>
>> Maybe you want to include that into Run_command(), that would make the
>> code
>> tidier.
>> Also when wait is in loop, I think one second is too long time, if there
>> is
>> multiple commands to execute...
>>
>>
>>
>>
>>> My problem is how to solve insertion of user name and password as well
>>> as the command 'ls -R'
>>>
>>
>> You can watch for some mark of end of execution, example:
>> Instead of:
>> ls -R
>>
>> Use:
>> ls -R ; echo '-->command executed<--'
>>
>> And in read event check when sStr includes that mark.
>>
>> There is no input at all after user name and password?
>> You cannot configure ftp server to give any?
>>
>> Maybe you need to use wait with those two... at the moment no good ideas
>> in
>> my mind.
>>
>>
>> Jussi
>> ------------------------------------------------------------------------------
>> Try before you buy = See our experts in action!
>> The most comprehensive online learning library for Microsoft developers
>> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
>> Metro Style Apps, more. Free future releases when you subscribe now!
>> http://p.sf.net/sfu/learndevnow-dev2
>> _______________________________________________
>> Gambas-user mailing list
>> Gambas-user at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
>




More information about the User mailing list