From 168aa76b2a7a795df6e6a96825c7d31d6a1e7ad8 Mon Sep 17 00:00:00 2001 From: HAYAMA_Kaoru Date: Thu, 5 Dec 2024 12:19:21 +0900 Subject: [PATCH] README: wrote about `(wait PID)` --- README.md | 65 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index c92593a..bc82106 100644 --- a/README.md +++ b/README.md @@ -17,37 +17,42 @@ Lispect (progn (format (error-output) "Usage: ~A ~A USERNAME@DOMAIN PASSWORD~%" $EXECUTABLE_NAME $PROGRAM_NAME) (return-from main nil))) - (defglobal account (car args)) - (defglobal password (cadr args)) - (with-handler - (lambda (c) - (format (error-output) "ssh is not found~%") - (return-from main nil)) - (spawn "ssh" account)) + (let ((account (car args)) + (password (cadr args)) + (sshpid nil)) - (expect* - ("[fingerprint])?" - (sendln "yes") - (expect "password: ") - (sendln password)) - ("password: " - (sendln password)) - (("Connection refused" - "Could not resolve hostname") - (return-from main nil)) - (30 - (format (error-output) "TIME OUT~%") - (return-from main nil))) + (with-handler + (lambda (c) + (format (error-output) "ssh is not found~%") + (return-from main nil)) + (setq sshpid (spawn "ssh" account))) - (expect* - ("Permission denied" - (return-from main nil) - ) - ("$ ")) - (sendln "echo YOU CAN CALL SOME COMMAND HERE") - (expect "$ ") - (sendln "exit")) + (expect* + ("[fingerprint])?" + (sendln "yes") + (expect "password: ") + (sendln password)) + ("password: " + (sendln password)) + (("Connection refused" + "Could not resolve hostname") + (return-from main nil)) + (30 + (format (error-output) "TIME OUT~%") + (return-from main nil))) + + (expect* + ("Permission denied" + (return-from main nil) + ) + ("$ ")) + (sendln "echo YOU CAN CALL SOME COMMAND HERE") + (expect "$ ") + (sendln "exit") + (wait sshpid) + ) + ) ``` Install @@ -92,7 +97,9 @@ Parameters enclosed in curly braces {...} are optional and can be omitted. - When STRING-n is found on the terminal, COMMANDS-n will be executed - After SEC seconds have elapsed, COMMANDS-FOR-TIMEOUT will be executed - `(spawn "COMMANDNAME" "ARG-1" ...)` - - Start the executable file + - Start the executable file and it returns Process-ID +- `(wait PID)` + - Wait the process specified with PID - `(getenv "NAME")` - Get the value of the environment variable NAME - `(setenv "NAME" "VALUE")`