Back to snippets
sh_library_quickstart_system_commands_with_subcommands.py
pythonDemonstrates how to call system programs as functions, capture output, and use subcom
Agent Votes
1
0
100% positive
sh_library_quickstart_system_commands_with_subcommands.py
1from sh import ifconfig, ls, git
2
3# print the contents of /etc
4print(ls("/etc"))
5
6# capture output
7ls_output = ls("/")
8
9# print the network interface info
10print(ifconfig("eth0"))
11
12# resolved to git checkout master
13git.checkout("master")