{"id":22998374,"url":"https://github.com/hymkor/lispect","last_synced_at":"2026-05-08T13:37:39.640Z","repository":{"id":265366529,"uuid":"895845802","full_name":"hymkor/lispect","owner":"hymkor","description":"A text-terminal automation tool similar to expect(1) using the subset of ISLisp","archived":false,"fork":false,"pushed_at":"2025-01-16T15:02:05.000Z","size":110,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-08T04:29:28.289Z","etag":null,"topics":["commandprompt","expect","go","golang","golang-application","golang-tools","islisp","lisp","terminal","windows"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hymkor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-29T03:07:53.000Z","updated_at":"2025-01-16T15:02:06.000Z","dependencies_parsed_at":"2024-12-24T12:35:30.582Z","dependency_job_id":"8da66b64-9fab-49c4-a805-7a881baa6bc5","html_url":"https://github.com/hymkor/lispect","commit_stats":null,"previous_names":["hymkor/lispect"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hymkor%2Flispect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hymkor%2Flispect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hymkor%2Flispect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hymkor%2Flispect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hymkor","download_url":"https://codeload.github.com/hymkor/lispect/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246820982,"owners_count":20839332,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["commandprompt","expect","go","golang","golang-application","golang-tools","islisp","lisp","terminal","windows"],"created_at":"2024-12-15T06:13:15.424Z","updated_at":"2026-05-08T13:37:39.631Z","avatar_url":"https://github.com/hymkor.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![GoDev](https://pkg.go.dev/badge/github.com/hymkor/lispect)](https://pkg.go.dev/github.com/hymkor/lispect)\r\n\r\nLispect\r\n=======\r\n\r\n- A text-terminal automation tool similar to [expect(1)] of UNIX and Linux\r\n- It runs on Windows 10 and later, and Linux\r\n- The script is written in the subset of [ISLisp] ([gmnlisp])\r\n\r\n[expect(1)]: https://linux.die.net/man/1/expect\r\n\r\n**example.lsp**\r\n\r\n$ `lispect example.lsp {SSH-OPTIONS} USERNAME@DOMAIN PASSWORD`  \r\n→ login `USERNAME@DOMAIN` with `ssh` and input `PASSWORD` automatically\r\n\r\n\u003e [!NOTE]\r\n\u003e Some variable names have been updated for compatibility with recent versions of gmnlisp, but the old names remain available for now.\r\n\r\n`lispect ./example.lsp -p 2222 username@127.0.0.1 yourpassword`\r\n\r\n```example.lsp\r\n(if (\u003c (length *argv*) 2)\r\n  (progn\r\n    (format (error-output) \"Usage: ~A ~A {SSH-OPTIONS} USERNAME@DOMAIN PASSWORD~%\" *executable-name* *program-name*)\r\n    (quit 1)))\r\n\r\n(let* ((ssh-param (subseq *argv* 0 (- (length *argv*) 1)))\r\n       (password (elt *argv* (- (length *argv*) 1)))\r\n       (sshpid nil))\r\n\r\n  (with-handler\r\n    (lambda (c)\r\n      (format (error-output) \"ssh is not found~%\")\r\n      (quit 2))\r\n    (setq sshpid (apply #'spawn \"ssh\" ssh-param)))\r\n\r\n  (expect*\r\n    (\"[fingerprint])?\"\r\n     (sendln \"yes\")\r\n     (expect \"password:\")\r\n     (sendln password))\r\n\r\n    (\"password:\"\r\n     (sendln password))\r\n\r\n    ((\"Connection refused\"\r\n      \"Could not resolve hostname\")\r\n     (quit 3))\r\n\r\n    (30\r\n     (format (error-output) \"TIME OUT~%\")\r\n     (quit 4)))\r\n\r\n  (expect*\r\n    (\"Permission denied\"\r\n     (expect \"password:\")\r\n     (send #\\U3)\r\n     (wait sshpid)\r\n     (quit 5))\r\n\r\n    (\"$ \")\r\n    )\r\n  (sendln \"echo YOU CAN CALL SOME COMMAND HERE\")\r\n  (expect \"$ \")\r\n  (sendln \"exit\")\r\n  (wait sshpid)\r\n  )\r\n```\r\n\r\nInstall\r\n-------\r\n\r\nDownload the binary package from [Releases](https://github.com/hymkor/lispect/releases) and extract the executable.\r\n\r\n### go install\r\n\r\n```\r\ngo install github.com/hymkor/lispect/cmd/lispect@latest\r\n```\r\n\r\n### scoop-installer\r\n\r\n```\r\nscoop install https://raw.githubusercontent.com/hymkor/lispect/master/lispect.json\r\n```\r\n\r\nor\r\n\r\n```\r\nscoop bucket add hymkor https://github.com/hymkor/scoop-bucket\r\nscoop install lispect\r\n```\r\n\r\nFunctions and variables\r\n-----------------------\r\n\r\nParameters enclosed in curly braces {...} are optional and can be omitted.\r\n\r\n- `(send {'interval MS} \"STRING\")`\r\n    - Send STRING to the terminal\r\n    - Specify the `'interval MS` option to make the program wait MS milliseconds before outputting each character\r\n- `(sendln {'interval MS} \"STRING\")`\r\n    - send STRING and Enter-key to the terminal\r\n- `(expect {'timeout SEC} \"STRING-0\" \"STRING-1\" ...)`\r\n    - Wait until STRINGs are found on the terminal\r\n    - When STRING-n is found on the terminal, it will return n\r\n    - If a timeout occurs after SEC seconds have elapsed, it returns -1\r\n- `(expect* (\"STRING-0\" COMMANDS-0...) (\"STRING-1\"...)... (SEC COMMANDS-FOR-TIMEOUT...))`\r\n    - When STRING-n is found on the terminal, COMMANDS-n will be executed\r\n    - After SEC seconds have elapsed, COMMANDS-FOR-TIMEOUT will be executed\r\n- `(spawn \"COMMANDNAME\" \"ARG-1\" ...)`\r\n    - Start the executable file and it returns Process-ID\r\n- `(wait PID)`\r\n    - Wait the process specified with PID\r\n- `(getenv \"NAME\")`\r\n    - Get the value of the environment variable NAME\r\n- `(setenv \"NAME\" \"VALUE\")`\r\n    - Set the value of the environment variable NAME as VALUE\r\n- `(quit {N})`\r\n    - Terminates the Lispect process with exit code `N` when running Lispect as a command-line executable.\r\n    - `N` must be an integer between 0 and 255. If omitted, the exit code defaults to `0`.\r\n    - When Lispect is used as a library (for example, calling `lispect.RunFile` or `lispect.RunString`), the process is **not** terminated. Instead, these functions return an error of type `exit.ExitError` corresponding to the requested exit code.\r\n- `*argv*` (formerly `ARGV`, now deprecated)[^1]  \r\n  The list of command-line arguments.\r\n- `*program-name*` (formerly `PROGRAM-NAME`, now deprecated)[^1]  \r\n  The path to the script.\r\n- `*executable-name*` (formerly `EXECUTABLE-NAME`, now deprecated)[^1]  \r\n  The path to the Lispect executable.\r\n- `*match*` (formerly `MATCH`, now deprecated)[^1]  \r\n  The matched string in an `(expect*)` block.\r\n- `(apply FUNCTION ARG-LIST)`\r\n    - Calls FUNCTION with arguments supplied as a list ARG-LIST.  \r\n      Useful when the number of arguments is dynamic or collected in a list.  \r\n      Example:\r\n      ```lisp\r\n      (setq args (list \"-p\" \"2222\" \"user@host\"))\r\n      (apply #'spawn \"ssh\" args)  ; equivalent to (spawn \"ssh\" \"-p\" \"2222\" \"user@host\")\r\n      ```\r\n- `(with-handler HANDLER FORM...)`\r\n    - When an error occurs in `FORMS...`, call `HANDLER`.\r\n      See also [ISLISP Draft - Operations relating to condition handling](https://islisp-dev.github.io/ISLispHyperDraft/islisp-v23.html#s_with_handler)\r\n\r\n[^1]: These variable names were changed to accommodate gmnlisp v0.7.10 and later, in which symbol names are case-insensitive. The new format avoids potential name conflicts.\r\n\r\nOther functions are defined on [ISLisp]\r\n\r\nComparison with [Expect-lua] and [expect(1)]\r\n--------------------------------------------\r\n\r\n|                       | [Expect-lua]          | Lispect       |[expect(1)]\r\n|-----------------------|-----------------------|---------------|-----------\r\n| Started               | 2017                  | 2024          | 1990?\r\n| Script                | Lua ([GophaLua])      | ISLisp ([gmnlisp]) | tcl\r\n| Windows 7/8           | Supported             | Not Supported | Not Supported\r\n| Windows 10/11         | Supported             | Supported     | Not Supported\r\n| Linux                 | Not Supported         | Supported     | Supported\r\n| Mechanisms            | [ReadConsoleOutputW]  |[PseudoConsole]| PseudoConsole\r\n| Read Misses           | Possible[^1]          | Unlikely      | Never\r\n| Stdout Redirection    | Unavailable           | Available     | Available\r\n| Status                | Stable                |Work in Progress| Stable\r\n\r\n[^1]: When the output is too excessive, there might be some dropped data\r\n\r\n[ReadConsoleOutputW]: https://github.com/hymkor/expect/issues/34\r\n[PseudoConsole]: https://learn.microsoft.com/en-us/windows/console/creating-a-pseudoconsole-session\r\n[Expect-lua]: https://github.com/hymkor/expect\r\n\r\nTechnologies used\r\n-----------------\r\n\r\n- [Creating a Pseudoconsole session - Windows Console | Microsoft Learn](https://learn.microsoft.com/en-us/windows/console/creating-a-pseudoconsole-session)\r\n- [aymanbagabas/go-pty: Cross platform Go Pty interface](https://github.com/aymanbagabas/go-pty)\r\n- [hymkor/gmnlisp: gmnlisp - the subset of ISLisp][gmnlisp]\r\n\r\n[ISLisp]: http://islisp.org\r\n[gmnlisp]: https://github.com/hymkor/gmnlisp\r\n[GophaLua]: https://github.com/yuin/gopher-lua\r\n\r\nAcknowledgements\r\n----------------\r\n\r\nThanks to the following contributors:\r\n\r\n- [@rwinkhart](https://github.com/rwinkhart) - [#1](https://github.com/hymkor/lispect/pull/1) : modularization support\r\n\r\nAuthor\r\n------\r\n\r\nThis project is developed and maintained by [@hymkor](https://github.com/hymkor)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhymkor%2Flispect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhymkor%2Flispect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhymkor%2Flispect/lists"}