How can i execute a shell (bash) command within a Common Lisp program and assign the output to a variable?
相关问题
- How to get the return code of a shell script in lu
- JQ: Select when attribute value exists in a bash a
- Generating powerset in one function, no explicit r
- Invoking Mirth Connect CLI with Powershell script
- Drakma and Dexador both fails at USocket call whil
相关文章
- 使用2台跳板机的情况下如何使用scp传文件
- In IntelliJ IDEA, how can I create a key binding t
- Check if directory exists on remote machine with s
- shell中反引号 `` 赋值变量问题
- How get the time in milliseconds in FreeBSD?
- What is the difference between execl and execv?
- Reverse four length of letters with sed in unix
- Launch interactive SSH bash session from PHP
ITA has released inferior-shell under their QITAB umbrella project.
Some links of possible interest :
A git repository is currently hosted at common-lisp.net :
This (appupdate.cl) program is an example of creating and executing a shell script using the Steel Bank Common Lisp (sbcl) implementation, which assumes you have sbcl installed and its in your path.
I wrote this on Ubuntu 14.04 as a simple way to perform the automation of the updating, upgrading, and kernel upgrading of the app/system software.
So of course it creates a shell script entitled update.sh, which is directed to /bin/bash via shebang (#!). After doing so the sb-ext:run-program built directs a shell to execute /bin/chmod passing the flag "+x" as an argument and the /path/to/the-file. This function changes the mode of access of the file to executable (changes the permissions).
Next, a shell is open and executes /bin/bash and the bash binary is passed the argument of the executable shell scripts file location.
Lastly the file is removed from the working directory (note in this case the appupdate.cl is in my home directory therefore is the working directory).
The appupdate.cl file can be executed from the command line after it is changed to executable and temporary root privileges are gained:
Easily enough the sudo command could be added to the script (e.g. sudo apt-get update) and using the sudo bash sequence would not be necessary.
NOTE: In the LispWorks ide on 14.04 the (sys:run-shell-command "") is still applicable even though it has sort of become a 'legacy' function.