run multiple non interacticve root commands
Posted
#1
(In Topic #1512)
Guru

password is held in memory and used with sudo and Process.Expect() when run
Posted
Regular

(Linear Programming job is progressing leaps and bounds. Pity I own none of it
It looks like what you did there might solve installs for the thousands of students that are going to use it. Would you believe hundreds? How about a few.
b
Posted
Guru

It's helped me.
I use the same class in my VBox-image mounter program. VirtualBox image mounter - Gambas ONE
It's a Static class,
I just use RootCommand(sCommand) where it needs it (to mount/unmount the vbox drives) and it only asks for password the first time.
Posted
Guru

I have used either a hidden TerminalView or just Exec/Shell process to run bash as su.
hBashProcess = Shell "pkexec env XAUTHORITY=" & Env["XAUTHORITY"] & " DISPLAY=" & Env["DISPLAY"] & " bash" For Input Output As "Proc"
Then use Write/Print to send the commands through the bash process.
Print #hBashProcess, sCommand
It works but has limitations with not knowing if the commands have finished running as Process.State relates to bash not the command it's running.
Also you have to exit bash before program closes.
The above RootCommander.class is better as it uses Process.Expect() on commands run directly (using sudo) So you can Check RootCommand.Process.State to see if the individual commands have finished running or not before allowing more.
Posted
Administrator

Now we're talkingBruceSteers said
A class to let your program start an internal process as root and use multiple commands.
password is held in memory and used with sudo and Process.Expect() when run
I might wanna have a look at this
gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories
… there is always a Catch if things go wrong!
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories
… there is always a Catch if things go wrong!
1 guest and 0 members have just viewed this.

