I have a python app in Gnu/Linux that change mac address in GUI. So I have to run pkexec command. I tried a lots of method with subprocess command with no luck. Can I anyone help to solve this problem? Now I run the app with 'sudo python3 app.py'.
wireless = config.get('wifi', 'wireless') <- This line gets from some file the name of wireless connection (wlx784476aae097)
subprocess.run(['pkexec', 'sh', '-c', 'ifconfig', wireless, 'down'])
subprocess.run(['pkexec', 'sh', '-c', 'ifconfig', wireless, 'up'])
Below 2 lines gets specifc mac address that type the user in GUI window that pop up then put it in variable with name 'text'.I didn't upload code for that.
text = self.lineEdit.text()
self.master.label_4.setText(text)
subprocess.run(['pkexec', 'sh', '-c', 'macchanger', '-m', text, wireless])
I am sorry for my english, I am not native speaker. All code is big, if above lines don't help I am able to upload all files with code. Thank you