[Gambas-user] No Graphical sudo program found
Brian G
brian at westwoodsvcs.com
Fri Jan 14 21:07:49 CET 2022
I have included a graphic gambas3 script to read a password bellow
in your main code that launches the sudo do the following I am using 'apt update' as an example:
exec ["sudo", "-A", "apt", "update"] with ["SUDO_ASKPASS=/home/brian/bin/getpassword"] wait
...........................................................^^^^^ this should be full path to getpassword
Hope this helps!
Here is a gambas3 script to just get the password and print it to the stdout:
Copy this section to a file called getpassword in your ~/bin directory or anywhere it is accessible by your app:
Save between the cut --------------------------------------- to the file getpassword
cut--------------------------------------------
#!/usr/bin/env gbs3
#Script Title="Get Password"
#Script Startup="FMain"
#Script Version="0.0.1"
Use "gb.image","gb.gui","gb.form"
class FMain
' Gambas class file
Public Sub Button1_Click()
Print PasswordEntry.text
FMain.Close()
End
End class
form FMain
# Gambas Form File 3.0
{ Form Form
MoveScaled(0,0,124,20)
{ Label1 Label
MoveScaled(3,6,20,8)
Text = ("Enter Password :")
}
{ !PasswordEntry TextBox
MoveScaled(26,5,74,11)
#Public = True
ToolTip = ("Enter your Password here")
Password = True
}
{ Button1 Button
MoveScaled(103,5,17,11)
Text = ("OK")
}
}
End form
cut -------------------------------------------------------
"Failure is the key to success;
each mistake teaches us something" .. Morihei Ueshiba
Brian G
----- On Jan 14, 2022, at 7:21 AM, Gambas mailing list user at lists.gambas-basic.org wrote:
> hello
>
> via command-line application,
>
> belote:
> Print "sudo fdisk -l ; your password ??"
> Input motdepasse
> Shell Subst("echo &1 | sudo -S fdisk -l &>/dev/stdout", motdepasse) To
> sortie
> If sortie Match "incorrect" Then
> Print "ko", ess
> If ess = 3 Then
> Print "3 attempts maxi. end"
> Goto fin
> End If
> Inc ess
> Goto belote
>
> Else
> Print sortie
> Endif
>
> (modify according to shell language)
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
More information about the User
mailing list