运行shell命令

runcmd的Python项目详细描述


安装
$ [sudo] pip install runcmd

class^{}
^{}Process class

函数

function^{}
^{}run command and return Process object

示例

>>>importruncmd>>>r=runcmd.run(["echo","hello world"])>>>r.code# exit status code0>>>r.out# stdout'hello world'>>>r.err# stderr''>>>r.pid# process pid1234

background=True

>>>r=runcmd.run(["sleep","5"],background=True)>>>whiler.running:# True if process is running and not "zombie process">>>print("running")

kill(signal=None)-终止进程

>>>r.kill(-9)

exc()-如果代码不是0,则引发异常

>>>runcmd.run(["ls"]).exc()# code 0, ok>>>runcmd.run(["mkdir","/"]).exc()# code 1, raise OSError...OSError:exitedwithcode1mkdir:/:Isadirectory

python-readme-generator

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java关闭应用程序按钮Listener   Java中的多线程同步在Java示例中的思考   java如何查看Tomcat正在使用/访问的JAR?   java My代码在调用垃圾收集器后不会终止   多线程Java连接线程池和connectionfactory?   java在运行时修改JAR文件   java Android:使用光标时引发IllegaleException   在Netbeans中测试不可执行库的java?   泛型在参数上强制子类Java类型   spring Java:继承与依赖注入“自动连线”   javascript如何解析这个xml元素   java打印特定序列中的数组   带有ProcessingTimeSessionWindow的java Apache Flink自定义触发器   java如何配置消息驱动的Bean应用程序和Glassfish来使用来自远程MessageBroker的消息?