我想在 python 脚本中运行一些命令
import fcntl
KDSETLED = 0x4B32
SCR_LED = 0x01
console_fd = os.open('/dev/console', os.O_NOCTTY)
fcntl.ioctl(console_fd, KDSETLED, SCR_LED)
我已经设置a+rw
好了,/dev/console
但是当我从普通用户运行脚本时:
fcntl.ioctl(console_fd, KDSETLED, SCR_LED) IOError: [Errno 1] Operation not allowed
如果我需要从普通用户运行该脚本,我该怎么办?