How to run command "sudo chmod -R 777 /path" in sikuli script?

Asked by Janet

I want to use run function in ubuntu as follow:

run("sudo chmod -R 777 /path")
or:
import os
os.system("sudo chmod -R 777 /path")

But it declares as below:
sudo: no tty present and no askpass program specified

How can i solve this problem?
How to run command with "sudo" effectively?

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

not possible this way, since sudo asks for the password interactively. run does not have a window.

I guess you have to open a windowed terminal session and paste the command and either paste the password afterwords or give it by hand.

Or have a look for an appropriate askpass program that you can use as suggested.

Revision history for this message
Tsung-Hsiang Chang (vgod) said :
#2

It's possible to ask sudo to read the password from stdin by using -S.

Can you help with this problem?

Provide an answer of your own, or ask Janet for more information if necessary.

To post a message you must log in.