Posted on 03-19-2024 03:32 AM
Hello !
I have a script that helps me to reconfigure printers and sets them by default depending of their location, department, etc...
The problem is that I can't set the ~/.cups/lpoptions by using lpoptions -d default_printer. To run the command, I use a function that I found and that executes it as the logged user.
If I execute the command as test:
launchctl asuser 502 sudo -u myuser /usr/bin/lpoptions -d default_printer, it does nothing. The lpoptions file is not populated. Even if I run the command line locally, it doesn't work. It only works if I run the script or the command line as the specific local user.
Any help is welcome !
Posted on 03-19-2024 07:40 AM
Well, I found how to manage this with "sudo -iu". I have used this command line in the past, but I got problems resolved with the "launchctl asuser" command, that doesn't work for me with the lpoptions command.