Page 1 of 1

GetHomeDirectory not worked

Posted: Sun Oct 20, 2024 6:26 pm
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?

Re: GetHomeDirectory not worked

Posted: Sun Oct 20, 2024 10:03 pm
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.

Re: GetHomeDirectory not worked

Posted: Mon Oct 21, 2024 7:57 am
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/

Re: GetHomeDirectory not worked

Posted: Mon Oct 21, 2024 8:26 am
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.