The Artima Developer Community
Sponsored Link

Python Buzz Forum
Lisp Scripting

2 replies on 1 page. Most recent reply: Aug 28, 2004 3:35 AM by Ng Pheng Siong

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Ng Pheng Siong

Posts: 410
Nickname: ngps
Registered: Apr, 2004

Ng Pheng Siong is just another guy with a website.
Lisp Scripting Posted: Aug 28, 2004 3:35 AM
Reply to this message Reply

This post originated from an RSS feed registered with Python Buzz by Ng Pheng Siong.
Original Post: Lisp Scripting
Feed Title: (render-blog Ng Pheng Siong)
Feed URL: http://sandbox.rulemaker.net/ngps/rdf10_xml
Feed Description: Just another this here thing blog.
Latest Python Buzz Posts
Latest Python Buzz Posts by Ng Pheng Siong
Latest Posts From (render-blog Ng Pheng Siong)

Advertisement

Scsh, pronounced "skishhhh" (rhymes with "fish"), is a Scheme shell. That is, it is a Unix shell which uses Scheme as its scripting language.

Here's an example script, from the scsh FAQ:

(define (executables dir)
  (with-cwd dir
     (filter file-executable? (directory-files dir #t))))
(define (writeln x) (display x) (newline))

(for-each writeln
   (append-map executables ((infix-splitter ":") (getenv "PATH"))))

Its Python equivalent, from above-mentioned FAQ:

import os, string, stat
for d in string.split(os.environ['PATH'], ':'):
   for f in os.listdir(d):
      mode = os.lstat(d + '/' + f)[stat.ST_MODE]
      if not stat.S_ISDIR(mode):
         print f

I haven't done any Scheme, actually. I've been scripting with CLISP. Here's a snippet from a backup script I wrote:

(defun backup ()
  (scp *src* (timestamp *dst* *file*)))

(backup)

Over time, should I write more such scripts, I might conceivably end up with a little language specific to system administration. Or I might just switch over to scsh. ;-)

Read: Lisp Scripting


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Lisp Scripting Posted: Aug 31, 2004 2:19 PM
Reply to this message Reply
It would probably be better to use os.sep and os.path.sep as well as os.path.join() in Python.

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Lisp Scripting Posted: Aug 31, 2004 2:21 PM
Reply to this message Reply
...And os.path.isdir() is a simpler than using stat.

Flat View: This topic has 2 replies on 1 page
Topic: perverted by language Previous Topic   Next Topic Topic: Doctors might soon ask,

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use