GetHomeDirectory not worked

Linux specific forum
User avatar
rndrei
Enthusiast
Enthusiast
Posts: 153
Joined: Thu Dec 28, 2023 9:04 pm

GetHomeDirectory not worked

Post by rndrei »

GetHomeDirectory function does not work!

Code: Select all

s$=GetHomeDirectory()+"data/file.dat"
PrintN(s$)
emits /root/data/file.dat And it should be /home/user/data/file.dat
What could be the problem?
User avatar
moulder61
Enthusiast
Enthusiast
Posts: 193
Joined: Sun Sep 19, 2021 6:16 pm
Location: U.K.

Re: GetHomeDirectory not worked

Post by moulder61 »

When I run your code it gives the following error:

[21:59:58] Waiting for executable to start...
[21:59:58] Executable type: Linux - x64 (64bit, Unicode)
[21:59:58] Executable started.
[21:59:58] [ERROR] Line: 2
[21:59:58] [ERROR] No console is currently opened. OpenConsole() must be called first.

I don't know if it helps at all, but this produces the expected output for me:

Code: Select all

s$=GetHomeDirectory()+"data/file.dat"
Debug s$
Moulder.
"If it ain't broke, fix it until it is!

This message is brought to you thanks to SenselessComments.com

My PB stuff for Linux: "https://u.pcloud.link/publink/show?code ... z3MR0T3jyV
User avatar
rndrei
Enthusiast
Enthusiast
Posts: 153
Joined: Thu Dec 28, 2023 9:04 pm

Re: GetHomeDirectory not worked

Post by rndrei »

I figured out what the problem was! When the program is run under sudo, it returns /root/, and when it is run under a regular user, it returns /home/user/. I need sudo to output /home/user/
User avatar
mk-soft
Always Here
Always Here
Posts: 6245
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: GetHomeDirectory not worked

Post by mk-soft »

If you write a file as sudo in a user directory is not good, because then the file has the authorisation of root and the user does not have full authorisation to the file.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Post Reply