Hyperfoil / qDup

Lab automation and queuing scripting
Apache License 2.0
12 stars 12 forks source link

Prompt needs to be adaptable to varying tool output text. #198

Closed whitingjr closed 11 months ago

whitingjr commented 1 year ago

The documentation indicates using prompt command when expecting interactive input from the user. This works fine except when the interactive tool changes the prompt text. eg psql command has changed over versions: Password: Password for user ****: The prompt needs to be adaptable to either of these strings. Trying to use a regex "Password.*: " does not seem to work.

willr3 commented 1 year ago

the prompt under sh and the add-prompt do not support regex pattern matching at this time although that is worth exploring. In the meantime they do support qDup pattern substitution with ${{..}}. If you know the user that is used for the psql command you could store that in a qDup state variable (a script level variable would work, no need to add it to states in yaml) and use that as part of the prompt: Password for user ${{userName}}:

whitingjr commented 1 year ago

good to know thanks. Sadly the environments have a variety of PG versions. Some will match but others not. The ability to use a regex will be very useful.

johnaohara commented 1 year ago

an alternative to entering the pword at prompt is to set the PGPASSWORD env variable using a secret and that should be portable across all PG versions

whitingjr commented 1 year ago

for the psql command there is no env variable support for PGPASSWORD.

jesperpedersen commented 1 year ago

https://dba.stackexchange.com/questions/14740/how-to-use-psql-with-no-password-prompt

whitingjr commented 1 year ago

using PGPASSWORD did work. ty PGPASSWORD=${{DB_PWD}} psql -h ${{DB_HOST}} -U ${{DB_USER}} ${{DB_SCHEMA}}