-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.lsp
44 lines (40 loc) · 1 KB
/
example.lsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
(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)
)
)