| print >> sys.stderr, "syntax: diff-opencloud <localfn> <remotehost:remotefn>" |
| print >> sys.stderr, "malformed desthost:destfn" |
| (hostname,destfn) = dest.split(":",1) |
| destfn = destfn + os.path.basename(srcfn) |
| script = 'echo START; base64 %s' % destfn |
| file("/tmp/script","w").write(script) |
| p = subprocess.Popen(["ssh", "-A", hostname], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
| (enctext,stderr) = p.communicate(input=script) |
| print >> sys.stderr, stderr |
| if "No such file" in stderr: |
| enctext = enctext.split("START")[1] |
| text = base64.b64decode(enctext) |
| file("/tmp/diff-src","w").write(text) |
| os.system("diff /tmp/diff-src %s" % srcfn) |
| echo "base64 -d -i > $DESTPATHNAME <<EOF" > /tmp/ssh-up |
| base64 $SRCPATHNAME >> /tmp/ssh-up |
| echo "EOF" >> /tmp/ssh-up |
| ssh -A $DESTHOSTNAME < /tmp/ssh-up |