Page 1 of 1

asdf:run-shell-command question

Posted: Mon Sep 27, 2010 9:16 pm
by sabra.crolleton
I know that if I run

Code: Select all

(asdf:run-shell-command "ls")
I get the return code from the shell function. Is there any way to actually get the output of the command (in this case, the actual directory listing) directly back? I can obviously have the output directed to a file and then have lisp read the file, then delete the file, but that is clumsy. The asdf manual simply lists the description for this function as a fixme.

I'm running sbcl. Other implementations may be different.

Thanks,

Sabra

Re: asdf:run-shell-command question

Posted: Mon Sep 27, 2010 11:37 pm
by ramarren
Do note that in current asdf the run-shell-command function is commented to not really fit in asdf package and might possibly be removed in a few years. It is best to use another compatibility system, although I am not sure if a good one exists, or external program facility specific to implementation (SBCL manual).

That said, as the docstring says, the output of the program is directed to *verbose-out*, and you can capture it using standard special variable stream techniques, for example:

Code: Select all

(with-output-to-string (asdf::*verbose-out*) (asdf:run-shell-command "ls"))
This will also capture the command itself. As mentioned, using this for purposes other than possibly calling an external compiler during asdf compilation process is not really recommended.

Re: asdf:run-shell-command question

Posted: Tue Sep 28, 2010 10:46 am
by Warren Wilkinson
Maybe you can use cl-fad? I've never written an asdf package so I don't really know. Alternatively, you could use cl-fad as a reference to write your own lisp code for fetching a listing. This would probably be more portable if that is of interest to you.

Re: asdf:run-shell-command question

Posted: Tue Sep 28, 2010 11:43 am
by nuntius
If you simply want ls, then cl-fad is probably the way to go (hint: ls doesn't work so well on ms-broken-windows).

If you really want to run other programs, then take a look at trivial-shell.

Re: asdf:run-shell-command question

Posted: Tue Sep 28, 2010 12:45 pm
by sabra.crolleton
Thanks all. Using ls was just the simplest example I could think of. Trivial-shell looks like what I need.

Now if I could find a cross platform decent entropy generator for true random numbers ... no one seems to be confident that (random) is really random for cryptography purposes and it has been on the TODO list for Ironport for awhile.

Sabra

Re: asdf:run-shell-command question

Posted: Wed Sep 29, 2010 6:57 pm
by nuntius
There are several CL implementations of the mersenne twister and other such algorithms. Unfortunately, I can't remember which was "best"... Here's three from a quick search.

http://cybertiggyr.com/jmt/
http://www.cliki.net/MT19937
http://www.ccs.neu.edu/home/dorai/notes/mrg32k3a.html

Re: asdf:run-shell-command question

Posted: Thu Sep 30, 2010 3:05 pm
by sabra.crolleton
From the Mersenne Twister Homepage FAQ: http://www.math.sci.hiroshima-u.ac.jp/~ ... /efaq.html

Mersenne Twister is not cryptographically secure. (MT is based on a linear recursion. Any pseudorandom number sequence generated by a linear recursion is insecure, since from sufficiently long subsequence of the outputs, one can predict the rest of the outputs.)

To make it secure, you need to use some Secure Hashing Algorithm with MT. For example, you may gather every eight words of outputs, and compress them into one word (thus the length of the output sequence is 1/8 of the original one).

I'm a database person, not a crypto person. The first rule of crypto seems to be "don't try this at home", so I'll have to think carefully about using this as an entropy source.

Sabra