#!/usr/bin/env mzscheme #lang scheme/base (require scheme/pretty scheme/system) ;; ssh invocation to make sure no default identities are tried from ;; the agent connection. ;; ssh -i -o "IdentitiesOnly yes" ;; ssh will concatenate all arguments into a single string and pass it ;; to the shell. in case shell is redirected, this command will end up ;; in SSH_ORIGINAL_COMMAND (define (parse x) (read (open-input-string x))) (define (with-log file thunk) (parameterize ((current-output-port (open-output-file file #:exists 'append))) (let ((retval (thunk))) (close-output-port (current-output-port)) retval))) (define (l x) (with-log "/tmp/dispatch.log" (lambda () (printf "~s\n" x) x))) (define command (l (or (getenv "SSH_ORIGINAL_COMMAND") (error 'no-ssh-command)))) ;; run shell (system command)