forked from tch2/git-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell.py
More file actions
28 lines (22 loc) · 666 Bytes
/
shell.py
File metadata and controls
28 lines (22 loc) · 666 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import subprocess
def ls():
output = subprocess.check_output(['ls']) # output is a string of everything returned
directory = output.split('\n') # split the string on newlines
directory.pop() # throw away the last, empty line
for filename in directory:
print filename
def lsl():
output = subprocess.check_output(['ls', '-l', '-h'])
directory = output.split('\n') # split the string on newlines
directory.pop() # throw away the last, empty line
for filename in directory:
print filename
def main():
print 'ls:'
ls()
print
print 'ls -l -h:'
lsl()
print
if __name__ == '__main__':
main()