[Gambas-user] Redirect to NULL with EXEC

Alex Schaller gambas at ...1077...
Wed Aug 24 15:44:55 CEST 2005


Hello Paul!

You could could execute the mount command thru a Gambas process and then read 
the output and error messages in the processes Read and error routines.

For the 1st. sample code below to work you will have to create a form and put 
a button and a textarea on it and then paste the code below in the forms 
class.

For the 2nd sample code (Konsole project) paste the code into the startup 
module.

Have a great day!
Alex

1st sample code------------------------------------------------------------

' Gambas class file

PRIVATE hProcess AS Process

PUBLIC SUB Button1_Click()

  DIM sExeString AS String

    textarea1.Clear
    sExeString = "mount /dev/hda6"
    hProcess = SHELL sExeString WAIT FOR READ

END

PUBLIC SUB Process_Error(sData AS String)
     textarea1.Text = textarea1.Text & "Error: " & sData & gb.NewLine
END

PUBLIC SUB Process_Read()

   DIM sLine AS String

   LINE INPUT #LAST, sLine
      textarea1.Text = textarea1.Text & sLine & gb.NewLine
 END


2nd sample code------------------------------------------------------------

' Gambas module file

PRIVATE hProcess AS Process
PRIVATE sExeString AS String

PUBLIC SUB Main()

  'DIM sExeString AS String

    sExeString = "mount /dev/hda6"
    hProcess = SHELL sExeString FOR READ

END

PUBLIC SUB Process_Error(sData AS String)

  ' Uncomment line below if you want to print a error message
  ' or add code to deal with different errors.
  'PRINT "Error executing  " & sExeString & ": " & gb.NewLine & sData

END


PUBLIC SUB Process_Read()

   DIM sLine AS String

   LINE INPUT #LAST, sLine
  ' Uncomment line below if you want to print a message
  'PRINT "Information from command " & sExeString & " :" & sLine
 END




More information about the User mailing list