On Fri, Sep 24, 2010 at 3:43 AM, Andreas Weiler < andreas.weiler@uni-konstanz.de> wrote:
Please do not use console if the user provides the password on the command
line with -P.
As i can see this is the case. The password is just read with the System.Console() when it is not specified after the -P argument.
That's not the problem. The problem is that you use System.console() when you should be using System.in in cases when the user specifies -P.
Try redirecting input from stdin to the BaseXClient - you'll see that it does not work. (It's a well-known limitation of java.io.Console). It leads to an infinite loop where BaseXClient ignores EOF. Really annoying.
Here for illustration what the problem is:
java -cp ../WEB-INF/lib/basex-6.2.3.jar org.basex.BaseXClient -p 1985 -U
admin -P admin BaseX 6.2.3 [Client] Try "help" to get some information.
create db test
Database 'test' created in 39.72 ms.
xquery insert node <root /> into doc("test")
Query executed in 29.36 ms.
xquery doc("test")/root
<root/> Query executed in 1.94 ms.
exit
Enjoy life.
Now when I put the commands in a file:
cat testscript
create db test xquery insert node <root /> into doc("test") xquery doc("test")/root exit
and then redirect stdin, it breaks:
java -cp ../WEB-INF/lib/basex-6.2.3.jar org.basex.BaseXClient -p 1985 -U
admin -P admin < testscript BaseX 6.2.3 [Client] Try "help" to get some information.
Database 'test' created in 8.71 ms.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
(and so on, I have to kill the program)
The reason is, as I said, that you're using java.io.Console when you should be using System.in
- Godmar