Thanks jf, that worked: (ns msms (:gen-class) (:use [clojure.contrib.shell-out :only (sh)]))
(defn get-msms-pts-OSX [{pdb-file :pdb-file density :density radius :radius :as all :or {density "1.0" radius "1.5"}}] (if (contains? all :pdb-file) (sh "bash" :in (str "/Users/daviddreisigmeyer/msms_MacOSX_2.6.1/ pdb_to_xyzr " pdb-file " > /Users/daviddreisigmeyer/lisps/clojure/dpa/src/hold.xyzr && " "msms.MacOSX.2.6.1" " -if /Users/daviddreisigmeyer/lisps/clojure/dpa/src/hold.xyzr" " -of /Users/daviddreisigmeyer/lisps/clojure/dpa/src/hold - no_header -density " density " -probe_radius " radius " && " "rm -f /Users/daviddreisigmeyer/lisps/clojure/dpa/src/hold.xyzr" " /Users/daviddreisigmeyer/lisps/clojure/dpa/src/hold.face")) (println "No pdb-file provided in get-msms-pts-OSX."))) Without the && in the system call: (defn get-msms-pts-OSX [{pdb-file :pdb-file density :density radius :radius :as all :or {density "1.0" radius "1.5"}}] (if (contains? all :pdb-file) ((sh "bash" :in (str "/Users/daviddreisigmeyer/msms_MacOSX_2.6.1/ pdb_to_xyzr " pdb-file " > /Users/daviddreisigmeyer/lisps/clojure/dpa/src/hold.xyzr")) (sh "bash" :in (str "msms.MacOSX.2.6.1" " -if /Users/daviddreisigmeyer/lisps/clojure/dpa/src/hold.xyzr" " -of /Users/daviddreisigmeyer/lisps/clojure/dpa/src/hold - no_header -density " density " -probe_radius " radius)) (sh "bash" :in (str "rm -f /Users/daviddreisigmeyer/lisps/clojure/ dpa/src/hold.xyzr" " /Users/daviddreisigmeyer/lisps/clojure/dpa/src/hold.face"))) (println "No pdb-file provided in get-msms-pts-OSX."))) I'd get the error: java.lang.String cannot be cast to clojure.lang.IFn Here it would only call the first command. If I added a println statement (defn get-msms-pts-OSX ((println "Hi") (sh "bash" :in (str "/Users/daviddreisigmeyer/msms_MacOSX_2.6.1/ pdb_to_xyzr " pdb-file " > /Users/daviddreisigmeyer/lisps/clojure/dpa/src/hold.xyzr")) (sh "bash" :in (str "msms.MacOSX.2.6.1" " -if /Users/daviddreisigmeyer/lisps/clojure/dpa/src/hold.xyzr" " -of /Users/daviddreisigmeyer/lisps/clojure/dpa/src/hold - no_header -density " density " -probe_radius " radius)) (sh "bash" :in (str "rm -f /Users/daviddreisigmeyer/lisps/clojure/ dpa/src/hold.xyzr" " /Users/daviddreisigmeyer/lisps/clojure/dpa/src/hold.face"))) (println "No pdb-file provided in get-msms-pts-OSX."))) it would run all three commands, and then print this error: No message. [Thrown class java.lang.NullPointerException] Can you see why this would be? Thanks again for your help, -Dave On Aug 8, 12:00 am, j-g-faustus <johannes.fries...@gmail.com> wrote: > On Aug 7, 4:46 pm, Dave <david.dreisigme...@gmail.com> wrote: > > > (execute (str "/../pdb_to_xyzr " pdb-file " > /.."))) > > > Here it seemed to run (the above error isn't shown) but nothing > > happened and the REPL become unresponsive again. > > I think the issue is that Runtime.exec doesn't start a shell, just a > subprocess, so things that are normally handled by the shell (like > redirection and pipes) doesn't work. > On > (execute "env | grep PATH") > I get "env: |: no such file or directory" - pipes and redirections are > passed as arguments to the first command rather than being handled by > the shell. > > > When I try: > > (sh :in (str "/...pdb_to_xyzr" pdb-file " > /...hold.xyzr"))) > > I get the following: > > No matching method found: exec for class java.lang.Runtime > > :in is the "standard in" for a command, but you haven't specified > which command. > > If you use "sh" as the command you get a shell and can use normal > shell syntax for the :in parameter. > > So this works: > user=> (sh "sh" :in "env | grep PATH") > "PATH=/usr/bin:/bin:/usr/sbin:/sbin\n" > user=> (sh "sh" :in "env > tmp.txt") > "" > > > Does anyone know why this doesn't seem to work: > > > (defn test-execute [ls-arg1 ls-arg2] > > (execute (str "ls -" ls-arg1)) > > (execute (str "ls -" ls-arg2))) > > As far as I can tell it does - it executes both commands, but returns > only the result of the last one. > If you want both, wrap them in a list or vector: > (defn test-execute [ls-arg1 ls-arg2] > (list > (execute (str "ls -" ls-arg1)) > (execute (str "ls -" ls-arg2)))) > > Regards > jf -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en