Page 1 of 1

shell to RunProgram() translation question

Posted: Thu Jun 29, 2017 2:29 pm
by Wolfram
Can someone translate this shell command to use it in RunProgram()?

Code: Select all

echo pw | sudo -S man dd

Re: shell to RunProgram() translation question

Posted: Sat Jul 01, 2017 6:48 pm
by vwidmer
Can try this

Code: Select all

Procedure.s BashRun(prun.s)
  Program = RunProgram("bash", "-c "+#DQUOTE$+prun.s+#DQUOTE$+"","", #PB_Program_Open|#PB_Program_Read)
  If Program
    While ProgramRunning(Program)
      If AvailableProgramOutput(Program)
        Output$ + ReadProgramString(Program) + Chr(13)
      EndIf
    Wend
    CloseProgram(Program) ; Close the connection to the program
  EndIf
  ProcedureReturn Output$
EndProcedure

OpenConsole()
Result$ = BashRun("echo pw | sudo -S man dd")
PrintN(Result$)
Debug Result$