Files
lispect/example.lsp
T

45 lines
1.0 KiB
Common Lisp

(catch 'fail
(if (< (length *argv*) 2)
(progn
(format (error-output) "Usage: ~A ~A USERNAME@DOMAIN PASSWORD~%" *executable-name* *program-name*)
(throw 'fail nil)))
(let ((account (car *argv*))
(password (cadr *argv*))
(sshpid nil))
(with-handler
(lambda (c)
(format (error-output) "ssh is not found~%")
(throw 'fail nil))
(setq sshpid (spawn "ssh" account)))
(expect*
("[fingerprint])?"
(sendln "yes")
(expect "password:")
(sendln password))
("password:"
(sendln password))
(("Connection refused"
"Could not resolve hostname")
(throw 'fail nil))
(30
(format (error-output) "TIME OUT~%")
(throw 'fail nil)))
(expect*
("Permission denied"
(expect "password:")
(send #\U3)
(wait sshpid)
(throw 'fail nil)
)
("$ "))
(sendln "echo YOU CAN CALL SOME COMMAND HERE")
(expect "$ ")
(sendln "exit")
(wait sshpid)
)
)