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: Shilen Patel <>
  • To: "Black, Carey M." <>, "" <>
  • Subject: Re: [grouper-users] GSH (new groovy based) ... passing in command line parameters?
  • Date: Wed, 2 May 2018 17:20:23 +0000
  • Accept-language: en-US
  • Authentication-results: oit.duke.edu; spf=none
  • Ironport-phdr: 9a23:FnOn2hyitvQE5DbXCy+O+j09IxM/srCxBDY+r6Qd2+MWIJqq85mqBkHD//Il1AaPAd2Araocw8Pt8InYEVQa5piAtH1QOLdtbDQizfssogo7HcSeAlf6JvO5JwYzHcBFSUM3tyrjaRsdF8nxfUDdrWOv5jAOBBr/KRB1JuPoEYLOksi7ze+/94HdbglSmDaxfa55IQmrownWqsQYm5ZpJLwryhvOrHtIeuBWyn1tKFmOgRvy5dq+8YB6/ShItP0v68BPUaPhf6QlVrNYFygpM3o05MLwqxbOSxaE62YGXWUXlhpIBBXF7A3/U5zsvCb2qvZx1S+HNsDtU7s6RSqt4LtqSB/wiScIKTg58H3MisdtiK5XuQ+tqwBjz4LRZoyeKfhwcb7Hfd4CRWRPQNtfVzBPDI2/YYsADeQOPedEoIbyvFYBtweyBQy2Ce/z0DJFhHn71rA63eQ7FgHG2RQtEc8OsHTVqNX6KqESWv2vwqbS0TXMcfdW0ir65YjTchAhoPWMUqx2ccfK1EYvCgDFgUuKpYP7IjyVy/0Avm6G5ORjTeKik3MrpgFvrjS1yMogkJTFi4ERx1ze6yl0z4g4KcWlREN7f9KoCpVduzuUOoZ5WM8vTXlkuCgkxbAFpZK2eS0Hx4g5yBLBbvGKd4uF4hz4W+uUJTp1i29pdba6ihux/0WtzvfzW8+p21hQtCVFiMPDtnUV2hzT9MeHTvx981+k2TmV1gDT7vhIIU86lKbCNpIswKQ8lp0SsUTfBCP5hVj2jKyIeUk+5Oen9vnnbq3npp+aKYB0lhnzPrkul8ChG+g1PBICU3WY9Om4zrHv40L0TbtSgv0ziKbZsZTaJcoBpq6+Bg9Yyp0j6xa+DzeiztsYm2IKI09YeBKEkYflIU/BL+3lDfunmVSjjC9rx+zaPr3mGpjNIWLDkLD8fbZl9UFc0hM/zc1E551KELEBO+n+WkvwtNzDEh85KBK4z/zmCNV7yoMRR3iPAqmHP6POr1OE/PwgLPSRZNxdhDGoYdIh7vXtyTcSkEUQbOGMm9FfPHq8F/9lZRzDOlLrmcpHHGsX6E52BuPwj0CaXCQWem2/RbkU5zcnBZigAJuZAI2hnfbJiCihGYBOa3oDF0uBC2zAdoOYVu0KZT7IZMJtj2pXe6KmTtoa1RCquQmy87N7I+6crjYYtJbu0vB5+u7e0xw+6GonXIymz2iRQjQszSszTDgs0fU6+BQlxw==
  • Spamdiagnosticmetadata: NSPM
  • Spamdiagnosticoutput: 1:99

Both changes are committed for 2.4.  I’ll check to make sure the upgrader can handle updates to gsh.sh as discussed on the call.

 

Thanks!

 

- Shilen

 

From: "Black, Carey M." <>
Date: Wednesday, May 2, 2018 at 10:24 AM
To: Shilen Patel <>, "" <>
Subject: RE: [grouper-users] GSH (new groovy based) ... passing in command line parameters?

 

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