Skip to content

Instantly share code, notes, and snippets.

@sleibrock
Last active April 24, 2020 15:42
Show Gist options
  • Save sleibrock/03a5533bd3affe1ec912abec2f900c22 to your computer and use it in GitHub Desktop.
Save sleibrock/03a5533bd3affe1ec912abec2f900c22 to your computer and use it in GitHub Desktop.
ssh-chat bot version 0.1
#lang racket/base
(define (start-bot)
(subprocess #f #f 'stdout
(find-executable-path "ssh")
"-p 2022"
"-o SetEnv TERM=bot"
"[email protected]"))
(define (generate-io sub)
(define-values (s stdout stdin e) (sub))
(define (read!) (read-line stdout 'return))
(define (write! msg)
(display (format "~a\r\n" msg) stdin)
(flush-output stdin))
(values s read! write!))
(define (main)
(define-values (sub read! write!)
(generate-io start-bot))
(define (loop)
(define v (read!))
(displayln v)
(sleep 1)
(loop))
(loop))
; end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment