hello,
I use the \c (connect) command in vsql to connect as a different user. I can only pass it the database name and user name. Is it possible to add the password to the command so that I don't have to type it when asked?
Password option for \c command in vsql?
Moderator: NorbertKrupa
-
- Beginner
- Posts: 42
- Joined: Thu Apr 19, 2012 9:03 pm
Re: Password option for \c command in vsql?
Hi!
From vsql? No. Outside vsql, in shell(bash/zsh/csh/ksh, whatever), you can by using aliases or write an execution wrapper.
Alias:
http://www.cyberciti.biz/tips/bash-alia ... -unix.html
http://www.linfo.org/alias.html
Wrapper example:
(I will show functions, but scripts are better. /opt/vertica/scripts/exec_vsql.sh is example for wrapper)
You can save function in "~/.bashrc" file for permanent usage (because function will lost when terminal will closed) and use in two "vsql" callers: for "dbadmin" and other user.
From vsql? No. Outside vsql, in shell(bash/zsh/csh/ksh, whatever), you can by using aliases or write an execution wrapper.
Alias:
http://www.cyberciti.biz/tips/bash-alia ... -unix.html
http://www.linfo.org/alias.html
Wrapper example:
(I will show functions, but scripts are better. /opt/vertica/scripts/exec_vsql.sh is example for wrapper)
Code: Select all
daniel@synapse:/tmp$ function vsql_fred { /opt/vertica/bin/vsql -U Fred "${1}" "${2}"; }
daniel@synapse:/tmp$ vsql_fred -c "\echo :USER"
Fred
daniel@synapse:/tmp$ vsql -c "\echo :USER"
daniel
-
- Beginner
- Posts: 42
- Joined: Thu Apr 19, 2012 9:03 pm
Re: Password option for \c command in vsql?
Thanks for you reply, sKwa. I'll try this out.