Page 1 of 1
Password option for \c command in vsql?
Posted: Mon Sep 23, 2013 8:45 pm
by billykopecki
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?
Re: Password option for \c command in vsql?
Posted: Mon Sep 23, 2013 9:18 pm
by id10t
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)
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
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.
Re: Password option for \c command in vsql?
Posted: Tue Sep 24, 2013 9:15 pm
by billykopecki
Thanks for you reply, sKwa. I'll try this out.