Skip to main content

Run program like bash scripts.

Project description

# PYSH

pysh是一个基于Python语法的脚本解释程序。

## 安装

` pip install pysh-run `

## 使用方法

  1. 基本用法

    `python from pysh.lib import Exec print(Exec("ls").stdout()) `

  2. 管道

    `python from pysh.lib import Exec print(Exec("cmd1").pipe_to(Exec("cmd2")).stdout()) print((Exec("cmd1") | Exec("cmd2")).stdout()) # 使用管道运算符 `

  3. 正则过滤

    `python from pysh.lib import Exec, Filter print(Exec("cmd1").pipe_to(Filter(".*\\.ps")).stdout()) print(Exec("cmd1").pipe_to(func).stdout()) # func的参数为cmd1的输出,输出结果为func的返回值 `

  4. xargs

    `python from pysh.lib import Exec Exec("lsof -i:8080").pipe_to("kill -9 $[1,1]").exec() # 前一个命令的输出内容作为后一个命令的参数 `

  5. &&

    `python from pysh.lib import Exec print(Exec("cmd1").success_to(Exec("cmd2")).stdout()) # cmd1执行成功才执行cmd2 `

  6. ||

    `python from pysh.lib import Exec print(Exec("cmd1").fail_to(Exec("cmd2")).stdout()) # cmd1执行失败才执行cmd2 `

  7. `python from pysh.lib import Exec print(Exec("cmd1").stream_to(Exec("cmd2")).stdout()) # 同时启动两个进程,把cmd1的输出实时写入cmd2 print(Exec("cmd1").stream_to(func).stdout()) # cmd1每输出一行,func被调用一次 `

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysh-run-1.1.tar.gz (13.5 kB view hashes)

Uploaded Source

Built Distribution

pysh_run-1.1-py3-none-any.whl (15.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page