shell not finishing execution
Posted
#1
(In Topic #1263)
Enthusiast

echo xxx | sudo -S dnf update -y
however if I put that into the shell command ….
it tells me it is checking the repos, the first thing it should show but nothing else happens. The shell is stopped and the update never happens. Why is the shell not remaining for the 20 minutes it should have taken? how do I make it do this?
Posted
Guru

Desktop.RunAsRoot("dnf update -y")
Posted
Enthusiast

Your solution is almost perfect, can we make it not ask for password and just take from the program?
Posted
Guru

/comp/gb.util/process/expect - Gambas Documentation
You can preset a password that way , apparently password prompt ends with :
So maybe…
Process.Expect("*:", "xxx")
Shell "sudo dnf upgrade -y" For input output
I can't test as at work but something along those lines.
Posted
Enthusiast

Posted
Guru

Posted
Guru

Posted
Enthusiast

Posted
Enthusiast

Posted
Guru

sadams54 said
tried the solution with the coding and the .expect is still not supported. throws error there. I even copied and pasted it. attempted to retype but the .expect is not there.
Did you add the gb.util component ?
Sorry Process.Expect is an enhancement provided by gb.util that's why it's under gb.util in the wiki
Posted
Enthusiast

Posted
Guru

Use Exec instead of Shell
End the shell command with 2>&1
Shell "the-command 2>&1"
That forces error (StdErr) messages to print to StdOut
Or something like this to check output and errors (sorry this code is hand written and not tested)
Code (gambas)
- TextAreaOutput.Text = "Udating...\n"
- aExec = ["sudo", "dnf" , "upgrade", "-y"]
- hProcess.Expect("*:", "xxx")
- ' hProcess.Wait ' I do not know if Process.Wait waits for the process to end or just for the next event so i use the loop below..
- Wait 0.1
- TextAreaOutput.Insert(sTxt)
- TextAreaOutput.Text &= "\nError: " & sTxt
Posted
Enthusiast

1 guest and 0 members have just viewed this.



