Skip to content
Snippets Groups Projects
Commit dc293c4e authored by Steve Dutcher's avatar Steve Dutcher
Browse files

bug fixes

parent 12e73def
Branches
Tags
No related merge requests found
...@@ -62,14 +62,14 @@ p = Popen(["./sftper", "--url", "sftp://localhost"], ...@@ -62,14 +62,14 @@ p = Popen(["./sftper", "--url", "sftp://localhost"],
Sending commands: Sending commands:
``` ```
import json, os, struct import json, os, struct
dat = json.dumps({"command": "LISTDIR", "args":{"path", "/path"}}).encode() dat = json.dumps({"command": "LISTDIR", "args":{"path": "/path"}}).encode()
p.stdin.write(struct.pack('!I', len(dat), dat)) p.stdin.write(struct.pack('!I', len(dat)) + dat)
``` ```
Receiving results in Python Receiving results in Python
``` ```
import json, os, struct import json, os, struct
num = struct.unpack('!I', p.stdout.read(4)) num = struct.unpack('!I', p.stdout.read(4))[0]
dat = p.stdout.read(num) dat = p.stdout.read(num)
assert len(dat) == num assert len(dat) == num
zult = json.loads(dat) zult = json.loads(dat)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment