Change to sudo user within a python script

前端 未结 8 1916
挽巷
挽巷 2020-11-29 05:33

I have a problem. I am writing a piece of software, which is required to perform an operation which requires the user to be in sudo mode. running \'sudo python filename.py\'

8条回答
  •  盖世英雄少女心
    2020-11-29 05:58

    Are you talking about having the user input password half way through your execution? raw_input() can take a user input from console, but it will not mask the password.

    >>>> y = raw_input()
    somehting
    >>> y
    'somehting'
    

提交回复
热议问题