0

I have two scripts that needs to be executed in chain. (First script calls the second script). The problem is that the first script needs sudo to function as expected, and the second script needs to be executed without sudo.

I've found and tried a few methods in my investigations but nothing worked. Following are the ways I tried:

$ sudo -Hu <currentUser> ./myscript.py  

$ dbus-launch ./myscript.py  

$ sudo -Hu <currentUser> dbus-launch ./myscript.py  

Any other way to get around this issue? and I have no idea why the dbus-launch is not working here, many sites suggested that it should work fine.

I'm using Ubuntu 18.04.

Simon Sudler
  • 3,931
  • 3
  • 21
  • 34
  • 1
    Tried to understand but little bit doubt "first script calls second script" where is first script and how is it calling second script? Can you el0b0rate? – PRATAP Dec 02 '19 at 10:12
  • The first script places certain values in a database.. and im currently using os.system to call the second script.. which uses the values placed by first script.. – frankenstein Dec 02 '19 at 11:22
  • @PRATAP The flow of the scripts has to remain the same, its kind of essential. – frankenstein Dec 02 '19 at 11:23
  • For a particular example, primary script places the details of wallpaper to be set(sudo required here) and second script has to set it to gsettings (thus troubles with sudo) – frankenstein Dec 02 '19 at 11:25
  • Good some how its clear.. to reproduce the issue.. you have two scripts one for certain values (this one is not clear) second one purely about setting the gsettings key values(this is clear). Can you el0b0rate certain values part please? – PRATAP Dec 02 '19 at 11:40
  • First part will something like, fetch the details of wallpaper (which to be applied) and store it in a location.. the second part reads from the location and applies to the current user. – frankenstein Dec 02 '19 at 13:00
  • @PRATAP ....... – frankenstein Dec 02 '19 at 13:29

0 Answers0