shell 脚本切换用户
2015-05-02 01:27
239 查看
有时需要root运行程序,但希望一般用户执行此程序,此时可以编写shell脚本首先切换到root,再来调用此程序。当然目标也可以采用"chmod u+s 你的程序“实现。
采用shell切换到root用户。
change2root.sh:
采用shell切换到root用户。
change2root.sh:
#!/usr/bin/expect expect -c " spawn su - expect "Password:" send yourpassword\n #此处为你的password,空格用"\ "表示, send \ \ \n表示当前密码为两空格 interact"
相关文章推荐
- shell,切换用户,执行指定,脚本
- Shell脚本中实现切换用户并执行命令操作
- 利用shell脚本提高效率(切换用户不需要输入密码)
- shell中自动切换用户删除日志小脚本
- shell脚本中切换用户执行相应的命令或者shell脚本的方法
- linux 普通用户登录后,执行 shell脚本切自动输入密码切换到root
- shell:expect实现非root用户切换脚本
- shell脚本中切换用户并执行命令
- shell脚本里切换用户执行命令的注意事项
- shell脚本 切换用户
- shell 脚本之切换用户
- shell脚本里切换用户执行命令的注意事项
- Shell脚本中实现切换用户并执行命令操作【转】
- shell 脚本之切换用户
- Shell脚本中实现切换用户并执行命令操作
- 用shell脚本创建用户
- shell切换用户EOF下变量的使用[: ==: unary operator expected
- ubuntu 切换用户的命令[shell, linux]
- 开关机自动执行脚本方法[以及切换用户执行命令方法]
- 在linux shell脚本中root切换到普通用户执行脚本或命令的方法