I'm not familiar with .exec, so this is a guess:

What you try to do is piping some text to some other program. This is
a shell feature, and I think .exec doesn't start a shell so you just
run 'echo' with some arguments. Try running a shell withing exec,
passing the commands as an argument to the shell.

On Mon, May 7, 2012 at 5:08 PM, Jim - FooBar(); <jimpil1...@gmail.com> wrote:
> Hello everyone,
>
> I was just messing about with the following function and cannot figure out
> why it won't work...
> I know that the command I'm passing to the runtime object is a valid unix
> command...i can execute it on my terminal no problem! Java however refuses
> send the "halt" signal to my ubuntu shell...any ideas?
> ---------------------------------------------------------------------------------------------------------------------------------
> (defn shutdown-pc [root-pwd minutes-after]
> (let [op-system  (System/getProperty "os.name")
>      enviroment (Runtime/getRuntime)]
> (cond
>    (or (.startsWith op-system "Linux")
>        (.startsWith op-system "Mac OS"))
>             (.exec enviroment (str "echo " root-pwd " |" " sudo -S shutdown
> -h +" minutes-after))
>        (.startsWith op-system "Windows")
>             (.exec enviroment (str "shutdown -s -t " minutes-after))
>    :else (throw (RuntimeException. "Unsupported operating system!"))))
> ----------------------------------------------------------------------------------------------------------------------------------
>
> Thanks in advance...
>
>
> Jim
>
> --
> 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



-- 
Moritz Ulrich

-- 
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

Reply via email to