在python命令行执行sudo命令
2024-08-28 07:06:22
def test():
sudoPassword = 'test'
command = '/opt/lampp/lampp stopmysql'
str = os.system('echo %s|sudo -S %s' % (sudoPassword, command))
print str
或:
(status, result)=commands.getstatusoutput('echo %s| sudo -S %s' %(PASSWORD,cmd))
最新文章
- 安装zeppelin
- maven install 构建报错(2)
- Python模拟实现Linux系统unix2dos功能
- MySQL查询语句完整语法解析
- Android 使用xml序列化器生成xml文件
- Java应用程序项目的打包与发行(run.bat形式)
- Lintcode: Merge Sorted Array II
- Nmap使用指南(1)
- tyvj 1055 区间dp
- 第三百零二天 how can I 坚持
- 【转】Contrary to the answers here, you DON'T need to worry about encoding!
- Cannot modify header information - headers already sent by
- mbed列--基于飞思卡尔FRDM KL25Z鼠标设计的高速实现
- bootstrap+jQuery.validate
- 重启oracle数据库的一次操作命令和alter日志。
- JavaScript中数组map()方法
- 分布式版本库——Windows下Git的环境部署以及在GitHub上开源自己的项目
- textarea去掉右下角拖拽
- openstack搭建之-glance配置(9)
- with(window) onload=onresize=function(){} 写法
热门文章
- c#和java中封装字段的不同
- CSS3 图标神器 =>; content:";我是特殊符号";
- 关于C#的强制转换和尝试转换的方法
- http协议的各类状态码
- 【10】Quartz.net 定时服务实例
- 10、List、Set
- Core.Java.Volume.I.Fundamentals.10th.Edition 14.5.8 Volatile域 中文版 章节勘误
- HDU 2546(01背包)
- 类库项目如何既能支持netcore2.0,也能支持net4.5
- vue项目性能优化(路由懒加载、gzip加速、cdn加速)