Last active
April 24, 2020 15:42
-
-
Save sleibrock/03a5533bd3affe1ec912abec2f900c22 to your computer and use it in GitHub Desktop.
ssh-chat bot version 0.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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