asdf:run-shell-command question

Discussion of Common Lisp
Post Reply
sabra.crolleton
Posts: 16
Joined: Sat Sep 13, 2008 6:46 pm

asdf:run-shell-command question

Post by sabra.crolleton » Mon Sep 27, 2010 9:16 pm

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

ramarren
Posts: 613
Joined: Sun Jun 29, 2008 4:02 am
Location: Warsaw, Poland
Contact:

Re: asdf:run-shell-command question

Post by ramarren » Mon Sep 27, 2010 11:37 pm

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.

Warren Wilkinson
Posts: 117
Joined: Tue Aug 10, 2010 11:24 pm
Location: Calgary, Alberta
Contact:

Re: asdf:run-shell-command question

Post by Warren Wilkinson » Tue Sep 28, 2010 10:46 am

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.
Need an online wiki database? My Lisp startup http://www.formlis.com combines a wiki with forms and reports.

nuntius
Posts: 538
Joined: Sat Aug 09, 2008 10:44 am
Location: Newton, MA

Re: asdf:run-shell-command question

Post by nuntius » Tue Sep 28, 2010 11:43 am

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.

sabra.crolleton
Posts: 16
Joined: Sat Sep 13, 2008 6:46 pm

Re: asdf:run-shell-command question

Post by sabra.crolleton » Tue Sep 28, 2010 12:45 pm

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

nuntius
Posts: 538
Joined: Sat Aug 09, 2008 10:44 am
Location: Newton, MA

Re: asdf:run-shell-command question

Post by nuntius » Wed Sep 29, 2010 6:57 pm

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

sabra.crolleton
Posts: 16
Joined: Sat Sep 13, 2008 6:46 pm

Re: asdf:run-shell-command question

Post by sabra.crolleton » Thu Sep 30, 2010 3:05 pm

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

Post Reply