I don't see this in the Netezza documentation.

We have lots of Linux scripts where we do this:

NzResult=$(nzsql -db ${NZ_DATABASE}  -u ${NZ_USER}  -pw $NZ_PASSWD_CLEAR -h $NZ_HOST \
              -qc "select 'hi there folks;'")

I don't like leaving the password hanging there in the command environment where it can be hacked.

Is there any kind of function to handle the password differently in the nzsql script? Did I miss something in the documentation? Or any tricks in Linux scripting I could use?

Thanks in advance....

1 Answer 1


Three options:

  • export it to the environment.
  • put it in the script
  • use nzpassword

the examples are off the top of my head, I don't have an instance to test it out right now, you might need to tweak them a bit.

exporting it to the environment:

NzResult=$(nzsql -db ${NZ_DATABASE}  -u ${NZ_USER} -h $NZ_HOST \
              -qc "select 'hi there folks;'")

Anyone who can read the environment variables set for your shell can still retrieve the password, but it won't show in the process list visible to everyone on the system

putting it in a script:

put the query in a sql file, add something like this at the top of it:

\echo *** connecting to MY_DATABASE ***
select 'hi there folks;'

Then use nzsql to execute this file. You may need to specify a login user to nzsql as well, but any user should do (even one that can only has no other rights besides log in)
Anyone who can read the sql file will be able to see the password, but I don't think it will show up anywhere else

using nzpassword

There is a tool to store passwords encrypted in a hidden ~/.nzpassword file, for later use, with:

nzpassword add -u user -pw password -host hostname

see: http://www-01.ibm.com/support/knowledgecenter/SSULQD_7.1.0/com.ibm.nz.adm.doc/c_sysadm_encrypted_passwords.html


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.