Skip to Content.
Sympa Menu

grouper-users - RE: [grouper-users] GSH (new groovy based) ... passing in command line parameters?

Subject: Grouper Users - Open Discussion List

List archive

RE: [grouper-users] GSH (new groovy based) ... passing in command line parameters?


Chronological Thread 
  • From: "Black, Carey M." <>
  • To: Shilen Patel <>, "" <>
  • Subject: RE: [grouper-users] GSH (new groovy based) ... passing in command line parameters?
  • Date: Wed, 2 May 2018 14:24:17 +0000
  • Accept-language: en-US
  • Authentication-results: spf=pass (sender IP is 128.146.138.8) smtp.mailfrom=osu.edu; duke.edu; dkim=none (message not signed) header.d=none;duke.edu; dmarc=pass action=none header.from=osu.edu;
  • Ironport-phdr: 9a23:hhH0+RXrEpPVxeUQd93R2uQ671/V8LGtZVwlr6E/grcLSJyIuqrYbR2Bt8tkgFKBZ4jH8fUM07OQ7/i7HzRYqb+681k6OKRWUBEEjchE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i764jEdAAjwOhRoLerpBIHSk9631+ev8JHPfglEnjWwba98IRmssQndqtQdjJd/JKo21hbHuGZDdf5MxWNvK1KTnhL86dm18ZV+7SleuO8v+tBZX6nicKs2UbJXDDI9M2Ao/8LrrgXMTRGO5nQHTGoblAdDDhXf4xH7WpfxtTb6tvZ41SKHM8D6Uaw4VDK/5KpwVhTmlDkIOCI48GHPi8x/kqRboA66pxdix4LYeZyZOOZicq/Ye94RWGhPUdtLVyFZAo2ycZYBD/YPM+hboYnypVoOogexCgS3Huzj1jtFi2Xq0aEm0eksFxzN0gw6H9IJtXTZtNv5OboWUe+v0KbIzi3PZO5I1Djn8ojHbBAgquyLU75qf8ba1E4iGBjBjlqKtYPlPCmZ2vkTv2WV9OdgUvmvi3M9pw5vvzev294hh4/UjYwW0lDJ7Tt1z5wpKdGlTUN3fMOoHIZVuiGUOIZ6Xt8uTmRmuCkkxbAKpZu2cS0IxZg7xRPTc/6KfoeS7h7+W+udPS10iXx7dL6lgxu+71CsyuPiWcS3zFpHqy9In9nQuX8R2Rze79aLR/R880i83DuC2ADe5+NKLE0xiaXUMIUuzaQ2m5EOq0rMBDX2l1/zjKKOdkUr5Oyo6+P/b7v+upKSMJN4hhznPqozgsKzHP00Mg8VUGeF4+i806Dj/VHiT7VNk/02lLTWvIrCJcQBoa65HxFa3Zo/6xa+CDem1s4UnX4aLFJZfBKHiI/pO1LULP/kCve/hkygkDZtx//YIr3sGovBIWLfnLv8eLtx9lNQxBc2wNBR6J9YFq0NLff9WkDvu9HUEho0Pgm2zur7CthxzoYeVniOAq+dPqPSq1iI5uc3LuaXYI8aoiryK/s/6/Lzk3M0l0QQfa6y3ZsKcny3AOlpI1iBbXr2ntgBCXsKvhY5TOHyh12CSzlTZ2uqX60i/DE3EZ+mDZzdSYC3m7yMxyO7HpxNZmBaEVCAD23kd4SCW/cQdi2SOMlhnSIYVbS/UYMuywyhtBKpg4Zge9HU+ykVs9rb3cR446WHjhEz8TFyJ8iA0GzLQm1pyCdADTAs271nrFY410yOy7NQgvpEGMZV6u8TFAo2KNSUm+NgDM3qVxiEY8yEUk2OQ9O6DCs3Q85rhdICfhAuNc+li0WJ9S6jCLxR35eCHpEluoealTClLcJ0wHWAjfN6p149X41COXDw1f03zBTaG4OcyxbRrK2tb6lJmXeVrGo=
  • Spamdiagnosticmetadata: NSPM
  • Spamdiagnosticoutput: 1:99

Shilen,

 

( Facepalm !! )  I did not understand the quoting difference between $* and “$@” before now in bash. How very subtle and different!

                The behavior felt like a quoting issue, but I just could not see how $* was dealing with the parameters before passing them into the first Java class. I has actually assumed the issue was later in the process. ( DOH! )

 

Thank you! That does fixes it.

 

Please…. Get that into 2.4 ( as a minimum. J )

Also… could I request one more change on that file (and it’s clones) while you are at it?

                Can you add the #! line at the top too? ( J Can I suggest:  #!/usr/bin/env bash)

 

 

 

 

 

Just to document for others and the fix (maybe a new automated test?):

Current ENV: grouper_v2_3_0_api_patch_79 ( not tested with later 2.3 patches )

 

The gsh (and gsh.sh ) scripts have a flaw that is a “one line fix”. ( correct the end of the line. Replace $*  , with “$@” )

NOTE: This file exists in a few places in a typical Grouper install: …/grouper.apiBinary-2.3.0/bin, …/grouper.ui-2.3.0/dist/grouper/WEB-INF/bin/, etc…

 

-       ${JAVA} -Xms$MEM_START -Xmx$MEM_MAX -Dgrouper.home="$GROUPER_HOME/" -Dfile.encoding=utf-8 $GSH_JVMARGS -classpath "${GROUPER_CP}" $GSH $*

+       ${JAVA} -Xms$MEM_START -Xmx$MEM_MAX -Dgrouper.home="$GROUPER_HOME/" -Dfile.encoding=utf-8 $GSH_JVMARGS -classpath "${GROUPER_CP}" $GSH "$@"

 

 

Sample script to test with (before and/or after fix)

REF: A simple one line script I was trying to test with file name= testCLI.gsh

     System.out.println('running testCLI.gsh  found x='+x)

 

Test process:

# this command line ( when after the patch) will set a gsh variable ‘x’ to a value of 3. Then load (and run) the testCLI.gsh script.

                ./gsh.sh -runarg 'x=3\n:load testCLI.gsh\n'

 

Before fix output:

groovy:000> :load /…/grouper.2.3/grouper.apiBinary-2.3.0/conf/groovysh.profile

groovy:000> x=3

===> 3

groovy:000> :load

Command ':load' requires at least one argument

groovy:000> :exit

 

 

After fix:

groovy:000> :load /…/grouper.2.3/grouper.apiBinary-2.3.0/conf/groovysh.profile

groovy:000> x=3

===> 3

groovy:000> :load testCLI.gsh

running testCLI.gsh found x=3

===> null

groovy:000>

groovy:000> :exit

 

--

Carey Matthew

 

From: Shilen Patel <>
Sent: Wednesday, May 2, 2018 5:44 AM
To: Black, Carey M. <>;
Subject: Re: [grouper-users] GSH (new groovy based) ... passing in command line parameters?

 

Hi,

 

GSH_JVMARGS is for system properties so that should work.

 

e.g.

 

export GSH_JVMARGS="-Dx=something"

 

 

Then your script has:

 

System.out.println("x="+System.getProperty("x"))

 

For runarg to work, I think gsh.sh has an issue.  Can you see if this change makes it behave correctly for you?

 

-       ${JAVA} -Xms$MEM_START -Xmx$MEM_MAX -Dgrouper.home="$GROUPER_HOME/" -Dfile.encoding=utf-8 $GSH_JVMARGS -classpath "${GROUPER_CP}" $GSH $*

+       ${JAVA} -Xms$MEM_START -Xmx$MEM_MAX -Dgrouper.home="$GROUPER_HOME/" -Dfile.encoding=utf-8 $GSH_JVMARGS -classpath "${GROUPER_CP}" $GSH "$@"

 

 

Thanks!

 

- Shilen

 

On 5/1/18, 11:30 PM, "" <> wrote:

 

    All,

   

    I have started to write a few GSH scripts and I am not clear on how I can pass in a "command line parameter" to the script.

                Specifically I am looking for "configuration variables" that would drive what the script does for this run.

   

    Should I look at using JVM properties?

                ./gsh appears to have a place holder for GSH_JVMARGS, but nothing setting it in that script... is that the best way (only way?) to do this task?

   

    

    I did look at GrouperShellWrapper and GrouperShell... which gave me some hope... but this did not work out... and it is not clear to me why it did not work...

   

    REF: ( a simple one line script I was trying to test with)   testCLI.gsh

     System.out.println('x='+x)

   

    Command line:

    ./gsh.sh -runarg 'x=3\n:load testCLI.gsh\n'

    OR

    ./gsh.sh -runarg '"x=3\n:load testCLI.gsh\n"'

   

    Produced:

    "

    groovy:000> :load /...../conf/groovysh.profile

    groovy:000> "x=3

    groovy:001> :load

    Command ':load' requires at least one argument

    groovy:001> :exit

    "

                I am really not clear why the testCLI.gsh part of the runarg string did not make it. (???)

   

    

    Any clue-bricks out there?

    

    --

    Carey Matthew

   

    

    




Archive powered by MHonArc 2.6.19.

Top of Page