passing format a list of strings

Started by two-, February 21, 2011, 01:16:14 AM

Previous topic - Next topic

two-

I have a function run-sh defined as so:(define (run-sh sTr) (exec (format {'%s'} sTr)))run-sh is a kind of basic function that takes input sTr - the shell command.

newLISP can call it like this:(run-sh {ls -a -l})or, so i wish. The problem is this is my error message:sh: ls -a -l: command not foundI know you're probably wondering 'why not use (exec ...?' but, let's say, if I wanted to do this, how can i pass a list of strings to run-sh such that the first string is the command name, and have newLISP pass the remaining strings as the command's arguments?

ยป; }

cormullion

#1
The single quotes are confusing the shell.


(define (run-sh sTr) (exec (format {%s} sTr)))
   (run-sh {ls -a -l})


This is possible:


(define (run-sh)
    (exec (format {%s} (join (args)))))

m i c h a e l

#2
cormullion?!



I've missed you! It's not the same place around here without you, but I certainly understand if you have other priorities now. I myself am not here as much as I'd like to be anymore :-(



Are you trying out other languages, or have you given up on programming altogether? Either way, it's good to hear from you again.



m i c h a e l

cormullion

#3
Hi michael - Yes, I just pop in occasionally to catch up on the excitement :) ... I don't have much time to do anything worth sharing...