mirror of
https://github.com/hymkor/lispect.git
synced 2026-08-27 20:36:34 -04:00
New example using ssh
This commit is contained in:
@@ -5,34 +5,41 @@ Lispect
|
|||||||
- It runs on Windows 10 and later, and Linux
|
- It runs on Windows 10 and later, and Linux
|
||||||
- The script is written in the subset of [ISLisp] ([gmnlisp])
|
- The script is written in the subset of [ISLisp] ([gmnlisp])
|
||||||
|
|
||||||
```example.lsp
|
**example.lsp**
|
||||||
(if (equal (getenv "OS") "Windows_NT")
|
|
||||||
(spawn "cmd.exe" "/k" "set PROMPT=$$$S")
|
|
||||||
(spawn "bash"))
|
|
||||||
|
|
||||||
(defglobal ctrlc (create-string 1 (convert 3 <character>)))
|
```example.lsp
|
||||||
(block main
|
(block main
|
||||||
(while t
|
(if (< (length args) 2)
|
||||||
(expect*
|
(progn
|
||||||
("xxx"
|
(format (error-output) "Usage: ./lispect example.lsp HOSTNAME PASSWORD~%")
|
||||||
(send ctrlc)
|
(return-from main nil)
|
||||||
(expect "$ ")
|
|
||||||
(sendln "exit")
|
|
||||||
(return-from main nil)
|
|
||||||
)
|
|
||||||
(("yyy" "zzz")
|
|
||||||
(send ctrlc)
|
|
||||||
(expect "$ ")
|
|
||||||
(sendln 'interval 200 "echo test")
|
|
||||||
)
|
|
||||||
(10 ; timeout second
|
|
||||||
(send ctrlc)
|
|
||||||
(expect "$ ")
|
|
||||||
(sendln "exit")
|
|
||||||
(return-from main nil)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
(defglobal host (car args))
|
||||||
|
(defglobal password (cadr args))
|
||||||
|
|
||||||
|
(spawn "ssh" host)
|
||||||
|
(expect*
|
||||||
|
("[fingerprint])?"
|
||||||
|
(sendln "yes")
|
||||||
|
(expect "password: ")
|
||||||
|
(sendln password)
|
||||||
|
)
|
||||||
|
("password: "
|
||||||
|
(sendln password)
|
||||||
|
)
|
||||||
|
("Connection refused"
|
||||||
|
(return-from main nil)
|
||||||
|
)
|
||||||
|
(30
|
||||||
|
(format (error-output) "TIME OUT~%")
|
||||||
|
(return-from main nil)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(expect "$ ")
|
||||||
|
(sendln "echo YOU CAN CALL SOME COMMAND HERE")
|
||||||
|
(expect "$ ")
|
||||||
|
(sendln "exit")
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
+33
-28
@@ -1,28 +1,33 @@
|
|||||||
(if (equal (getenv "OS") "Windows_NT")
|
(block main
|
||||||
(spawn "cmd.exe" "/k" "set PROMPT=$$$S")
|
(if (< (length args) 2)
|
||||||
(spawn "bash"))
|
(progn
|
||||||
|
(format (error-output) "Usage: ./lispect example.lsp HOSTNAME PASSWORD~%")
|
||||||
(defglobal ctrlc (create-string 1 (convert 3 <character>)))
|
(return-from main nil)
|
||||||
(block main
|
)
|
||||||
(while t
|
)
|
||||||
(expect*
|
(defglobal host (car args))
|
||||||
("xxx"
|
(defglobal password (cadr args))
|
||||||
(send ctrlc)
|
|
||||||
(expect "$ ")
|
(spawn "ssh" host)
|
||||||
(sendln "exit")
|
(expect*
|
||||||
(return-from main nil)
|
("[fingerprint])?"
|
||||||
)
|
(sendln "yes")
|
||||||
(("yyy" "zzz")
|
(expect "password: ")
|
||||||
(send ctrlc)
|
(sendln password)
|
||||||
(expect "$ ")
|
)
|
||||||
(sendln 'interval 200 "echo test")
|
("password: "
|
||||||
)
|
(sendln password)
|
||||||
(10 ; timeout second
|
)
|
||||||
(send ctrlc)
|
("Connection refused"
|
||||||
(expect "$ ")
|
(return-from main nil)
|
||||||
(sendln "exit")
|
)
|
||||||
(return-from main nil)
|
(30
|
||||||
)
|
(format (error-output) "TIME OUT~%")
|
||||||
)
|
(return-from main nil)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
(expect "$ ")
|
||||||
|
(sendln "echo YOU CAN CALL SOME COMMAND HERE")
|
||||||
|
(expect "$ ")
|
||||||
|
(sendln "exit")
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user