Hi Corona688,
thank you very much for the code.
Quote:
# If we are not the owner of the file, restart this script from the beginning
# as $NEWUSER via sudo.
[ "$USER" = "$NEWUSER" ] || exec sudo -u "$NEWUSER" "$0" "$@"
I am not an expert on Linux and script, so, could you please explain better the statements above? I am not sure what I need to do when you say: restart this script from the beginning as $NEWUSER via sudo.
I thought that the script should executed at once, no matter the owner. Even I need to execute the script again how to execute the script as sudo, how would it be? Just remembering, the application will send to Linux the script execution, and the execution needs to be at once - there is no interactive session to execute the script, I am not able to send to Linux 2 commands, just 1.
what happen if I always consider that the user/owner is different and sudo is always executed? (even if I could have the owner as the user)
tks.