Run program like bash scripts.
Project description
# PYSH
pysh是一个基于Python语法的脚本解释程序。
## 安装
` pip install pysh-run `
## 使用方法
- 基本用法
`python from pysh.lib import Exec print(Exec("ls").stdout()) `
- 管道
`python from pysh.lib import Exec print(Exec("cmd1").pipe_to(Exec("cmd2")).stdout()) print((Exec("cmd1") | Exec("cmd2")).stdout()) # 使用管道运算符 `
- 正则过滤
`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的返回值 `
- xargs
`python from pysh.lib import Exec Exec("lsof -i:8080").pipe_to("kill -9 $[1,1]").exec() # 前一个命令的输出内容作为后一个命令的参数 `
- &&
`python from pysh.lib import Exec print(Exec("cmd1").success_to(Exec("cmd2")).stdout()) # cmd1执行成功才执行cmd2 `
- ||
`python from pysh.lib import Exec print(Exec("cmd1").fail_to(Exec("cmd2")).stdout()) # cmd1执行失败才执行cmd2 `
- 流
`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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pysh-run-1.1.tar.gz.
File metadata
- Download URL: pysh-run-1.1.tar.gz
- Upload date:
- Size: 13.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7e6f31bc7b3f7c9968dad4e6e0560968f49162c96d5e3f1ac2dfdc33dbff5ae
|
|
| MD5 |
1e4e09993316921bff9839a09a4edb06
|
|
| BLAKE2b-256 |
4912cddc368778363eabd2a32a4907dc414e0cc108c51396cf6792e08583d11c
|
File details
Details for the file pysh_run-1.1-py3-none-any.whl.
File metadata
- Download URL: pysh_run-1.1-py3-none-any.whl
- Upload date:
- Size: 15.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9827d38759d3ab8ddf3191bb04b3d1b4339b10f0527fe477fcc0c3e16c934974
|
|
| MD5 |
64e8ee741c70753f6e3f08005116c22d
|
|
| BLAKE2b-256 |
8d27a98d182599fbac6b216712d58f3f425d4ab3c9f40eba266e559f8fe637f2
|