[gambit-list] how to exec shell command then collect result as a string? (like with perl $a=`ls`; )
Marc Feeley
feeley at iro.umontreal.ca
Sun May 27 16:22:43 EDT 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 27-May-07, at 3:31 PM, Guillaume Germain wrote:
> You could do something like:
>
> (read-line (open-process "ls") #f)
And if you need to interact several times with the program over stdin/
stdout you can do something like this:
> (define bc (open-process "bc"))
> (display "1+2\n" bc)
> (force-output bc)
> (read-line bc)
"3"
> (display "3*4\n" bc)
> (force-output bc)
> (read-line bc)
"12"
> (close-port bc)
> (process-status bc)
0
"bc" is the Unix arbitrary precision calculator. If maple can also
interact over stdin/stdout then this would be an appropriate interface.
If you want to do this with other Scheme implementations, check out
the "processio" Snow package (http://snow.iro.umontreal.ca/?
viewpkg=processio).
Marc
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (Darwin)
iD8DBQFGWeiT//V9Zc2T/v4RAsIrAKCslD48fCBrXQMUzQksTGJ3JhD9TQCglG3L
7KBO1aF5wMJ2UaMTVAoYycw=
=Qyie
-----END PGP SIGNATURE-----
More information about the Gambit-list
mailing list