diff --git a/README.md b/README.md index 74a1ef03b8f12e9df696df894218689119d76c1d..03e516b539ebb6dc0e382148f207a2f69207df43 100644 --- a/README.md +++ b/README.md @@ -62,14 +62,14 @@ p = Popen(["./sftper", "--url", "sftp://localhost"], Sending commands: ``` import json, os, struct -dat = json.dumps({"command": "LISTDIR", "args":{"path", "/path"}}).encode() -p.stdin.write(struct.pack('!I', len(dat), dat)) +dat = json.dumps({"command": "LISTDIR", "args":{"path": "/path"}}).encode() +p.stdin.write(struct.pack('!I', len(dat)) + dat) ``` Receiving results in Python ``` 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) assert len(dat) == num zult = json.loads(dat)