Python执行或远程执行shell命令
最近想要实现通过脚本循环再 Linux 下运行 shell 命令,经过探索发现使用 Python 语言有几种解决方案,在此简单记录。 方案一:脚本本地执行命令 在 Python 中有两个库都可以实
最近想要实现通过脚本循环再 Linux 下运行 shell 命令,经过探索发现使用 Python 语言有几种解决方案,在此简单记录。
方案一:脚本本地执行命令
在 Python 中有两个库都可以实现运行 shell 命令的效果:
1 |
|
使用方法也很简单:
1 |
|
方案二:脚本远程执行命令
在 Python 中有一个库可以实现 SSH 客户端及 SFTP 的功能。
1 |
|
使用方法大致如下:
1 |
|
方案三:使用 SecureCRT 脚本
该方法参见此前的博文:SecureCRT 下 Python 脚本编写
参考文献
- Python 学习总结 06 paramiko 远程执行命令:https://www.cnblogs.com/wangshuo1/p/6265360.html
- Python 模块学习 - Paramiko:https://www.cnblogs.com/xiao-apple36/p/9144092.html
- python 中执行 linux 命令(调用 linux 命令):https://blog.csdn.net/shanliangliuxing/article/details/8811701
- (转)python 中执行 linux 命令:https://blog.csdn.net/laiahu/article/details/6697930
- python 执行 linux 命令的三种方式:https://zhuanlan.zhihu.com/p/100946961
Python执行或远程执行shell命令
https://www.frytea.com/post/20201022053400.html