[Gambas-user] Program to use different group rights
Rolf-Werner Eilert
rwe-sse at osnanet.de
Mon Nov 26 18:08:56 CET 2018
Sorry got you wrong, this works perfectly!
Just oversaw the pipe and echo trick...
Thanks a lot!
Rolf
Am 26.11.2018 um 17:21 schrieb T Lee Davidson:
> How about this:
>
> Public Sub Main()
>
> Dim sPass, sOutput As String
>
> sPass = "wrong"
> Shell "echo " & sPass & "|su -c True $USER 2>&1" To sOutput
> ' Print sOutput
> If InStr(sOutput, "failure") > 0 Then
> Print "Fail"
> Else
> Print "Pass"
> Endif
>
> End
>
>
> ___
> Lee
>
>
> On 11/26/18 7:02 AM, Rolf-Werner Eilert wrote:
>> Let me add this:
>>
>> I just found two solutions:
>>
>> 1. Commandline:
>>
>> if su -c true "$USER"; then
>> echo "Correct password"
>> fi
>>
>> How would I read the exit code if in a Gambas shell?
>>
>> 2. PAM call. This example is in Ruby, but very much like Gambas. BUT it needs a Ruby library called rpam, so if there is nothing
>> comparable in Gambas...
>>
>> It boils down to this line:
>>
>> if Rpam.auth(username, password, service: 'system-auth')
>>
>> So I would prefer the first way, but I need to know how to read exit codes from a shell.
>>
>> Regards
>> Rolf
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>
>
More information about the User
mailing list