New example using ssh

This commit is contained in:
HAYAMA_Kaoru
2024-12-02 06:27:26 +09:00
parent 31510725b1
commit 3c5630327a
2 changed files with 64 additions and 52 deletions
+31 -24
View File
@@ -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
View File
@@ -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")
)