从Scheme(Guile)执行命令行 [英] Execute command line from Scheme (Guile)

查看:220
本文介绍了从Scheme(Guile)执行命令行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题描述在标题上,基本上我想从scheme中执行命令行,比如说'ls'并获取输出.所以我的问题是:

The question is described on the title, basically I'd like to execute a command line from scheme, let's say 'ls' and obtaining the output. So my questions are:

  • 有可能吗?
  • 如何?

非常感谢!

通过我使用Guille的方式.

By the way I use Guille.

推荐答案

您需要这些systemsystem*之一.

示例:(system "ls")

摘自文档:《 Guile参考》

— Scheme Procedure: system [cmd]
— C Function: scm_system (cmd)
Execute cmd using the operating system's "command processor". Under Unix this is usually the default shell sh. The value returned is cmd's exit status as returned by waitpid, which can be interpreted using the functions above.

If system is called without arguments, return a boolean indicating whether the command processor is available.

— Scheme Procedure: system* . args
— C Function: scm_system_star (args)
Execute the command indicated by args. The first element must be a string indicating the command to be executed, and the remaining items must be strings representing each of the arguments to that command.

This function returns the exit status of the command as provided by waitpid. This value can be handled with status:exit-val and the related functions.

system* is similar to system, but accepts only one string per-argument, and performs no shell interpretation. The command is executed using fork and execlp. Accordingly this function may be safer than system in situations where shell interpretation is not required.

Example: (system* "echo" "foo" "bar")

这篇关于从Scheme(Guile)执行命令行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆