GroovyServのショートパス問題についての実験
試してなかった。
時間があいてしまったけど、いろいろ試してみた。
経緯
Windowsのショートネーム変換の~sがバグってるのでGroovyServ0.9の起動に失敗する場合がある
僕
>startコマンドに食わせる必要があるので
>(startはダブルクォートをつけるとNGという超う○こ仕様)
空白を含むパスの場合は "" をタイトルに指定して、以下のように
すればいいということではない?
id:nobeans / [twitter:@nobeans]
あれ、できます?
そう思って実際試したのにダブルクォートがある場合はNGだった、という記憶だけがあります。
groovyserver.batの187行目辺りなんですけど、ダブルクォートで囲って動きますかね(今動作する環境がないので試せない)
id:nobeans / [twitter:@nobeans]
ああ、やっぱりそうだ。最初""で囲ってたけど動かなくて戻したんだった。
https://github.com/kobo/groovyserv/commit/458b8aa3b7f3ffea8e940d1575f8a2db85b54f03
なんだろう、178行目の方は""が不要だったけど、187行目は残さないといけなかったというオチかしら。
#今、動作確認環境がないので、適当に書いてます
環境
Windows XP
Groovy 1.8.1
Java 1.7.0
結論
groovyservのプロセスは起動したけど、これでいいんだっけ?
正解がわからなくなった。。。
実験1 ""でくくってみる
修正
--- オリジナル Sun Oct 02 17:45:08 2011 +++ 修正後 Sun Oct 02 17:46:00 2011 @@ -184,7 +184,7 @@ start ^ "groovyserver[port:%GROOVYSERVER_PORT%]" ^ /MIN ^ - %GROOVY_BIN% ^ + "%GROOVY_BIN%" ^ %GROOVYSERV_OPTS% ^ -e "println('Groovyserver^(port %GROOVYSERVER_PORT%^) is running');println('Close this window to stop');org.jggug.kobo.groovyserv.GroovyServer.main(args)" if errorlevel 1 (
結果
'C:\usr\opt\groovy\GROOVY~2.1\bin\groovy.bat" -Dgroovyserver.port=1961
-e "println' は、内部コマンドまたは外部コマンド、
操作可能なプログラムまたはバッチ ファイルとして認識されていません。NG
本当だ。ダメだ。
なんでだろう?
実験2 シュートパスをロングパスに変換して、コマンドプロンプトから実行
実行
c:\>start "groovyserver[port:1961]" /MIN "C:\usr\opt\groovy\groovy-1.8.1\bin\groovy.bat" -Dgroovyserver.port=1961 -e "println('Groovyserver^(port 1961^) is running');println('Close this window to stop');org.jggug.kobo.groovyserv.GroovyServer.main(args)"
c:\>
結果
'C:\usr\opt\groovy\groovy-1.8.1\bin\groovy.bat" -Dgroovyserver.port=1961 -e "println' は、内部コマンドまたは外部コマンド、操作可能なプログラムまたはバッチ ファイルとして認識されていません。 c:\>
NG
実験3 groovy.bat に渡してるオプションをなくしてみる
実行
c:\>c:\>start "groovyserver[port:1961]" /MIN "C:\usr\opt\groovy\groovy-1.8.1\bin\groovy.bat" c:\>
結果
error: neither -e or filename provided
usage: groovy [options] [args]
options:
-a,--autosplit <splitPattern> split lines using splitPattern (default '\s')
using implicit 'split' variable
-c,--encoding <charset> specify the encoding of the files
-classpath <path> Specify where to find the class files - must
be first argument
-cp,--classpath <path> Aliases for '-classpath'
-D,--define <name=value> define a system property
-d,--debug debug mode will print out full stack traces
--disableopt <optlist> disables one or all optimization elements.
optlist can be a comma separated list with
the elements: all (disables all
optimizations), int (disable any int based
optimizations)
-e <script> specify a command line script
-h,--help usage information
-i <extension> modify files in place; create backup if
extension is given (e.g. '.bak')
-l <port> listen on a port and process inbound lines
(default: 1960)
-n process files line by line using implicit
'line' variable
-p process files line by line and print result
(see also -n)
-v,--version display the Groovy and JVM versions
c:\>NG
これは、コマンドのパスではなくて、Groovy.batに渡すコマンドパラメータ側っぽいな。
実験4 Groovy.batに渡すコマンドパラメータをシンプルにしてみる
実行
[c:\]start "groovyserver[port:1961]" /MIN "C:\usr\opt\groovy\groovy-1.8.1\bin\groovy.bat" -Dgroovyserver.port=1961 -e print"test"
結果
'C:\usr\opt\groovy\groovy-1.8.1\bin\groovy.bat" -Dgroovyserver.port=1961 -e print"test' は、内部コマンドまたは外部コマンド、操作可能なプログラムまたはバッチ ファイルとして認識されていません。
NG
Groovy.batに渡すコマンドパラメータの""がダメなのかな。
実験5
実行
Groovy.batに渡しているオプションを""から''にしてみる
c:\>start "groovyserver[port:1961]" /MIN "C:\usr\opt\groovy\groovy-1.8.1\bin\groovy.bat" -Dgroovyserver.port=1961 -e print'test' c:\> |< ***結果 >|| test c:\>
OK
これは、動いた。
原因
Groovy.batに渡すコマンドパラメータの""がダメなんだな。
-e "println('Groovyserver^(port 1961^) is running');println('Close this window to stop');org.jggug.kobo.groovyserv.GroovyServer.main(args)"
実験6 バッククオートだとどうなる?
c:\>start "groovyserver[port:1961]" /MIN "C:\usr\opt\groovy\groovy-1.8.1\bin\groovy.bat" -Dgroovyserver.port=1961 -e `println('Groovyserver^(port 1961^) is running');println('Close this window to stop');org.jggug.kobo.groovyserv.GroovyServer.main(args)`
c:\>org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
script_from_command_line: 1: unexpected char: '`' @ line 1, column 1.
`println('Groovyserver(port
^
1 error
||<|
<span class="deco" style="color:#FF0000;font-size:x-large;">NG</span>
**実験7 \でエスケープはどうなる?
>||
c:\>start "groovyserver[port:1961]" /MIN "C:\usr\opt\groovy\groovy-1.8.1\bin\groovy.bat" -Dgroovyserver.port=1961 -e \"println('Groovyserver^(port 1961^) is running');println('Close this window to stop');org.jggug.kobo.groovyserv.GroovyServer.main(args)\"指定されたパスが見つかりません。 c:\>
NG
実験8 バッチのエスケープは^だったけ、^ならどうなる?
c:\>start "groovyserver[port:1961]" /MIN "C:\usr\opt\groovy\groovy-1.8.1\bin\groovy.bat" -Dgroovyserver.port=1961 -e ^"println('Groovyserver^(port 1961^) is running');println('Close this window to stop');org.jggug.kobo.groovyserv.GroovyServer.main(args)^"'C:\usr\opt\groovy\groovy-1.8.1\bin\groovy.bat" -Dgroovyserver.port=1961 -e "println' は、内部コマンドまたは外部コマンド、操作可能なプログラムまたはバッチ ファイルとして認識されていません。 c:\>
NG
振り出しに戻った( ̄▽ ̄;)
実験9 問題の箇所をバッチ化してみる
start ^ "groovyserver[port:%GROOVYSERVER_PORT%]" ^ /MIN ^ Startgroovyserver.bat
@echo off %GROOVY_BIN% ^ %GROOVYSERV_OPTS% ^ -e "println('Groovyserver^(port %GROOVYSERVER_PORT%^) is running');println('Close this window to stop');org.jggug.kobo.groovyserv.GroovyServer.main(args)"
Groovyserver(port 1961) is running Close this window to stop
c:\>groovyclient
Invoking server: "groovyserver.bat" -p 1961
Groovy home directory: "C:\usr\opt\groovy\GROOVY~2.1"
Groovy command path: "C:\usr\opt\groovy\GROOVY~2.1\bin\groovy.bat" (found at GROOVY_HOME)
GroovyServ home directory: "C:\usr\opt\groovy\groovy-1.8.1\bin\.."
GroovyServ work directory: "C:\Documents and Settings\orangeclover\.groovy\groovyserv"
Original classpath: c:\.;C:\usr\opt\java\jre6\lib\ext\QTJava.zip
GroovyServ default classpath: "c:\.;C:\usr\opt\java\jre6\lib\ext\QTJava.zip;C:\usr\opt\groovy\groovy-1.8.1\bin\..\lib\*"
Starting........
error: neither -e or filename provided
usage: groovy [options] [args]
options:
-a,--autosplit <splitPattern> split lines using splitPattern (default '\s')
using implicit 'split' variable
-c,--encoding <charset> specify the encoding of the files
-classpath <path> Specify where to find the class files - must
be first argument
-cp,--classpath <path> Aliases for '-classpath'
-D,--define <name=value> define a system property
-d,--debug debug mode will print out full stack traces
-e <script> specify a command line script
-h,--help usage information
-i <extension> modify files in place; create backup if
extension is given (e.g. '.bak')
-l <port> listen on a port and process inbound lines
(default: 1960)
-n process files line by line using implicit
'line' variable
-p process files line by line and print result
(see also -n)
-v,--version display the Groovy and JVM versions
usage: groovyclient -C[option for groovyclient] [args/options for groovy]
options:
-Ch,-Chelp show this usage
-Cp,-Cport <port> specify the port to connect to groovyserver
-Ck,-Ckill-server kill the running groovyserver
-Cr,-Crestart-server restart the running groovyserver
-Cq,-Cquiet suppress statring messages
-Cenv <substr> pass environment variables of which a name
includes specified substr
-Cenv-all pass all environment variables
-Cenv-exclude <substr> don't pass environment variables of which a
name includes specified substr
c:\>NG?
プロセスの起動はするけど、groovyclientがエラーになるな。。。
あれ?オリジナルに戻しても同じだな。
Starting.........
error: neither -e or filename provided
usage: groovy [options] [args]
options:
-a,--autosplit <splitPattern> split lines using splitPattern (default '\s')
using implicit 'split' variable
省略
groovyclientが、どうなるのが正しいのかがわからなくなった。。。
Windows環境で、groovyservのプロセスが起動した後、
groovyclientは、どのように表示されればいいの? > id:nobeans / [twitter:@nobeans]
Windows環境でのgroovyclientの実行結果を
コメントに貼りつけてもらえると助かる。
>[twitter:@kimukou_26] [twitter:@fumokmm ] [twitter:@kijuky]