Re: Clojure shell calls results inconsistent with actual shell calls.

2012-07-16 Thread Eric in San Diego
Thanks for everyone's input.

I think at this point I've concluded that this is not a clojure problem, 
but rather something going on with the program I'm calling in the shell.  
I'm talking to the support community there.


In the meantime I've found a work-around.

Thanks again for everyone's help!

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

Re: Clojure shell calls results inconsistent with actual shell calls.

2012-07-15 Thread Anthony Grimes
You don't have to post your whole application, but you really, really need 
to give us a small example that causes your problem. We can't work with "I 
did x with y and it doesn't work.". Try to water down an isolated piece of 
code that we can run that causes your issue.

On Wednesday, July 11, 2012 6:47:33 PM UTC-5, Eric in San Diego wrote:
>
>
> It's very application specific, but it's "Object 'test' does not have a 
> field named 'test1' c:/path/to/importTest", suggesting that it's not 
> inferring the value of an  'I' parameter which should indicate a directory 
> within which to search for a file called 'test' which included some trivial 
> code that informs my test.
>
> I tried substituting a batch file (this is on windows) with the single 
> line in it, and get the same discrepency in behavior - the batch file works 
> fine when invoked from the shell, but fails when called with sh.  This 
> suggest to me that it's nothing to do with clojure's processing of the 
> arguments. Maybe this has something to do with how the environment is 
> represented?
>
> I tried printing the value of sh/*sh-env* during my call, and it was 
> 'nil', but in order to call the app at all, it must have some knowledge of 
> the PATH. Does (null *sh-env*)  then mean 'no changes to the default 
> environment'?
>
>
> On Wednesday, July 11, 2012 3:53:48 PM UTC-7, Michael Klishin wrote:
>>
>> Eric in San Diego: 
>>
>> > That's why I'm hoping there is some way I can compare and contrast the 
>> actual inputs that get fed into the app. 
>>
>> At least post your exception message. 
>>
>> MK 
>>
>> mich...@defprotocol.org 
>>
>>

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

Re: Clojure shell calls results inconsistent with actual shell calls.

2012-07-15 Thread Denis Labaye
On Thu, Jul 12, 2012 at 12:21 AM, Eric in San Diego wrote:

> In a shell, I can call
>
> > app arg1 arg2 arg3 arg4 arg5 arg6 arg7
>
> and get my expected results.
>
> However, if I make what I think is the same call programmatically in
> clojure:
>
> (ns ...
>(:require [clojure.java.shell :as sh]
>))
>
> (defn test []
>(sh/sh "app" "arg1" "arg2" "arg3" "arg4" "arg5" arg6" "arg7"))
>
> my app is throwing an error. Is there some way to get at the difference
> between the args as passed from the command-line and the args as passed
> from the shell call?
>
> I would add that this approach has always worked in the past, not clear
> why this particular app is the exception.
>
> Thanks for any help.


Beware of the shell expansion!

For example:

In a terminal: ls *.clj will list all files ending with .clj.

In the Clojure REPL: (sh "ls" "*.clj") will do something different: List
all files named clj, as Clojure won't expand your wildcard but
pass the "*.clj" as is.

Denis


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

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

Re: Clojure shell calls results inconsistent with actual shell calls.

2012-07-12 Thread John Szakmeister
On Wed, Jul 11, 2012 at 7:47 PM, Eric in San Diego  wrote:
>
> It's very application specific, but it's "Object 'test' does not have a
> field named 'test1' c:/path/to/importTest", suggesting that it's not
> inferring the value of an  'I' parameter which should indicate a directory
> within which to search for a file called 'test' which included some trivial
> code that informs my test.

This doesn't sound like a problem with sh, but in the way you're
calling it.  Without a traceback, and some sample source though, it's
harder to give useful feedback.  Perhaps, you're doing something
slightly unexpected, and the script isn't coping with it well?  For
instance, you're doing the equivalent of:

   (sh/sh "testApp" "-I c:/path/to/importTest")

Instead of:

   (sh/sh "testApp" "-I" "c:/path/to/importTest")

In the first case, testApp is called with 1 argument "-I
c:/path/to/importTest".  In the second case, it's called with 2
arguments, just as it would be with the shell.

> I tried substituting a batch file (this is on windows) with the single line
> in it, and get the same discrepency in behavior - the batch file works fine
> when invoked from the shell, but fails when called with sh.  This suggest to
> me that it's nothing to do with clojure's processing of the arguments. Maybe
> this has something to do with how the environment is represented?

Is it the script that's failing?  From sh, you should get a map of
:in, :out, and :err.  If you're getting that, then the problem is
definitely lower (in the script) versus in sh.

> I tried printing the value of sh/*sh-env* during my call, and it was 'nil',
> but in order to call the app at all, it must have some knowledge of the
> PATH. Does (null *sh-env*)  then mean 'no changes to the default
> environment'?

IIRC, the "set" command will dump your environment in Windows.  "env"
will do it under Linux or Mac OS X.  You can do:
(print (sh/sh "env"))

(print (sh/sh "set")) should work in Windows... but I don't run
Windows, so I can't be certain. *sh-env* is a thread local binding,
and can be used to customize the environment for several calls via
(with-sh-env ...).  The 'nil' you're seeing is the default binding
value, which means "take the parent environment".  (sh ...) does allow
you to override the environment too using the :env keyword.

-John

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


Re: Clojure shell calls results inconsistent with actual shell calls.

2012-07-11 Thread Eric in San Diego

It's very application specific, but it's "Object 'test' does not have a 
field named 'test1' c:/path/to/importTest", suggesting that it's not 
inferring the value of an  'I' parameter which should indicate a directory 
within which to search for a file called 'test' which included some trivial 
code that informs my test.

I tried substituting a batch file (this is on windows) with the single line 
in it, and get the same discrepency in behavior - the batch file works fine 
when invoked from the shell, but fails when called with sh.  This suggest 
to me that it's nothing to do with clojure's processing of the arguments. 
Maybe this has something to do with how the environment is represented?

I tried printing the value of sh/*sh-env* during my call, and it was 'nil', 
but in order to call the app at all, it must have some knowledge of the 
PATH. Does (null *sh-env*)  then mean 'no changes to the default 
environment'?


On Wednesday, July 11, 2012 3:53:48 PM UTC-7, Michael Klishin wrote:
>
> Eric in San Diego: 
>
> > That's why I'm hoping there is some way I can compare and contrast the 
> actual inputs that get fed into the app. 
>
> At least post your exception message. 
>
> MK 
>
> mich...@defprotocol.org 
>
>

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

Re: Clojure shell calls results inconsistent with actual shell calls.

2012-07-11 Thread Michael Klishin
Eric in San Diego:

> That's why I'm hoping there is some way I can compare and contrast the actual 
> inputs that get fed into the app.

At least post your exception message.

MK

mich...@defprotocol.org



signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: Clojure shell calls results inconsistent with actual shell calls.

2012-07-11 Thread Peter Buckley
Have you already tried println'ing the args out, and/or constructing a single 
line like this?

(def problem-cmd (str "app" "arg1" "arg2" "etc"))

(sh/sh problem-cmd)

-Original Message-
From: Eric in San Diego 
Sender: clojure@googlegroups.com
Date: Wed, 11 Jul 2012 15:21:03 
To: 
Reply-To: clojure@googlegroups.com
Subject: Clojure shell calls results inconsistent with actual shell calls.

In a shell, I can call

> app arg1 arg2 arg3 arg4 arg5 arg6 arg7

and get my expected results.

However, if I make what I think is the same call programmatically in 
clojure:

(ns ...
   (:require [clojure.java.shell :as sh]
   ))

(defn test []
   (sh/sh "app" "arg1" "arg2" "arg3" "arg4" "arg5" arg6" "arg7"))

my app is throwing an error. Is there some way to get at the difference 
between the args as passed from the command-line and the args as passed 
from the shell call?

I would add that this approach has always worked in the past, not clear why 
this particular app is the exception.

Thanks for any help.


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

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

Re: Clojure shell calls results inconsistent with actual shell calls.

2012-07-11 Thread Michael Gardner
On Jul 11, 2012, at 5:40 PM, Eric in San Diego wrote:

> Unfortunately the application in question is kinda...involved.  It's a call 
> to a tool provided by a third party, and installing the whole thing is 
> non-trivial.
> 
> That's why I'm hoping there is some way I can compare and contrast the actual 
> inputs that get fed into the app.

Could you temporarily replace your third-party tool with a shell script that 
just spits its arguments to some file? That, or just start digging into the 
source for clojure.java.shell.

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


Re: Clojure shell calls results inconsistent with actual shell calls.

2012-07-11 Thread Eric in San Diego

Unfortunately the application in question is kinda...involved.  It's a call 
to a tool provided by a third party, and installing the whole thing is 
non-trivial.

That's why I'm hoping there is some way I can compare and contrast the 
actual inputs that get fed into the app.

On Wednesday, July 11, 2012 3:23:38 PM UTC-7, Michael Klishin wrote:
>
> Eric in San Diego: 
>
> > my app is throwing an error 
>
> How about posting the error (and a snippet of your code)? Bonus points for 
> a Github repository that can be used 
> to reproduce. 
>
> MK 
>
> 
>
>

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

Re: Clojure shell calls results inconsistent with actual shell calls.

2012-07-11 Thread Michael Klishin
Eric in San Diego:

> my app is throwing an error

How about posting the error (and a snippet of your code)? Bonus points for a 
Github repository that can be used
to reproduce.

MK

mich...@defprotocol.org



signature.asc
Description: Message signed with OpenPGP using GPGMail