1

How to assign a parameter/argument in postgres psql UPDATE command. I tried with the following command.

c="openssl rand -base64 6"
ab=eval $c
psql -d db_name -c "UPDATE table_name SET password = '$ab' WHERE name = 'cde'" 

The above command updates the table 'table_name' in the colum 'password' as ' ' (quotes with empty string)instead of updating the value of '$ab'. The '$ab' is a string.

Could anyone help on this?

1 Answer 1

1

This is the way it works:

c="openssl rand -base64 6"
ab=`$c`
psql -d db_name -c "UPDATE table_name SET password = '$ab' WHERE name = 'cde'" 
Sign up to request clarification or add additional context in comments.

1 Comment

Why don't you just write ab=$( openssl rand -base64 6 ) to start with?

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.