[Gambas-user] EXEC ... WITH
Tobias Boege
tobs at taboege.de
Mon Jul 19 01:22:07 CEST 2021
On Sun, 18 Jul 2021, jose.rodriguez at cenpalab.cu wrote:
> This works in cli:
>
> pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY /home/joe1962/0-develop/MyDev/vcpufreq/trunk/vcpufreq-gui/vcpufreq-gui.gambas
>
> However, none of the following attempts have worked in Gambas code:
>
> Exec ["pkexec", "env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY " & Application.Path &/ "vcpufreq-gui.gambas"] Wait
>
If you use Exec, you have to split arguments properly by space.
There is no shell to do it for you. I suppose what you want is
Exec ["pkexec", "env", "DISPLAY=" & Env["DISPLAY]", "XAUTHORITY=" & Env["XAUTHORITY"], Application.Path &/ "vcpufreq-gui.gambas"] Wait
> Exec ["pkexec", Application.Path &/ "vcpufreq-gui.gambas"] With ["DISPLAY=$DISPLAY", "XAUTHORITY=$XAUTHORITY"] Wait
>
Gambas does not interpret $DISPLAY and $XAUTHORITY. With this
"With" statement, you are putting the literal string values
"$DISPLAY" and "$XAUTHORITY" into these environment variables.
The "$variable" syntax for environment variable expansion is
a shell feature. With Exec, you bypass the shell and renounce
its features.
What you should do from Gambas is to use Env[] as I did above.
But I suppose pkexec clears the environment, which is the reason
why it has an "env" subcommand. If that's the case, then setting
the environment using "With" will not get you anywhere. You should
instead try what I suggest in my first paragraph.
Best,
Tobias
--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
More information about the User
mailing list