Skip to content
Snippets Groups Projects
Commit 10bc72bc authored by Neil Gershenfeld's avatar Neil Gershenfeld
Browse files

wip

parent 06624532
Branches
No related tags found
No related merge requests found
...@@ -31,6 +31,7 @@ s.write(b'\x01') # ^a enter raw mode ...@@ -31,6 +31,7 @@ s.write(b'\x01') # ^a enter raw mode
while (s.in_waiting > 0): # clear buffer while (s.in_waiting > 0): # clear buffer
s.read() s.read()
if (sys.argv[2] == 'run'): if (sys.argv[2] == 'run'):
s.write(b'\x04') # ^d reset
s.write(b'\x03') # ^c interrupt s.write(b'\x03') # ^c interrupt
file = open(sys.argv[3],'r') file = open(sys.argv[3],'r')
str = file.read() str = file.read()
...@@ -42,6 +43,7 @@ if (sys.argv[2] == 'run'): ...@@ -42,6 +43,7 @@ if (sys.argv[2] == 'run'):
while (True): # show output while (True): # show output
sys.stdout.write(s.read().decode('utf-8')) sys.stdout.write(s.read().decode('utf-8'))
elif (sys.argv[2] == 'ls'): elif (sys.argv[2] == 'ls'):
s.write(b'\x04') # ^d reset
s.write(b'\x03') # ^c interrupt s.write(b'\x03') # ^c interrupt
s.write(b'import os\n') s.write(b'import os\n')
s.write(b'files = os.listdir()\n') s.write(b'files = os.listdir()\n')
...@@ -54,6 +56,7 @@ elif (sys.argv[2] == 'ls'): ...@@ -54,6 +56,7 @@ elif (sys.argv[2] == 'ls'):
sys.stdout.write(s.read().decode('utf-8')) sys.stdout.write(s.read().decode('utf-8'))
print('') print('')
elif (sys.argv[2] == 'put'): elif (sys.argv[2] == 'put'):
s.write(b'\x04') # ^d reset
s.write(b'\x03') # ^c interrupt s.write(b'\x03') # ^c interrupt
file = open(sys.argv[3],'r') file = open(sys.argv[3],'r')
str = file.read() str = file.read()
...@@ -72,6 +75,7 @@ elif (sys.argv[2] == 'put'): ...@@ -72,6 +75,7 @@ elif (sys.argv[2] == 'put'):
sys.stdout.write(s.read().decode('utf-8')) sys.stdout.write(s.read().decode('utf-8'))
print('') print('')
elif (sys.argv[2] == 'get'): elif (sys.argv[2] == 'get'):
s.write(b'\x04') # ^d reset
s.write(b'\x03') # ^c interrupt s.write(b'\x03') # ^c interrupt
s.write(bytes(f'file = open("{sys.argv[3]}","r")\n','ascii')) s.write(bytes(f'file = open("{sys.argv[3]}","r")\n','ascii'))
s.write(b'print(file.read())\n') s.write(b'print(file.read())\n')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment