How to pass encrypted passwords to a batch script
search cancel

How to pass encrypted passwords to a batch script

book

Article ID: 89875

calendar_today

Updated On:

Products

CA Automic Workload Automation - Automation Engine

Issue/Introduction

How to pass encrypted passwords to a batch script

Environment

Release: AOATAM99000-9.0-Automic-One Automation Tools-Application Manager
Component:

Resolution

Symptoms

1) Is it possible to pass an encrypted password to batch file or shell script?

2) Can the password be an encrypted static parameter (or var) that can be passed to the batch file?


Resolution

1) If you are running this in powershell as an interpreted job, then the '&UC_JOBMD CMD "xx"' has to be called as external program from powershell or any other interpreter job.

For ex.: in powershell you can invoke the expression - shell.exec, &,...

so you would use whatever best fits your needs.

:INC SQLPASS.INC

:set &job_md#=get_var('UC_EX_JOB_MD','&$AGENT#')

$exe='&job_md#'

& $exe CMD="echo &PASS#" | set-variable pass

:set &script#=STR_CAT(&PATH_SQL#,&SQL#)

!Command to run SQLPlus

!Output of SQL Script is outputed to the Job Report

!&LOGIN# is the user name, &con_str# is the ORACLE SID starting with @ if needed

sqlplus &LOGIN#/${pass}&con_str# '@&script#'


evaluated withe a username of support, and a connection string of @supportdb, and a script of script.sql, this comes out to:

sqlplus support/[password]@supportdb '@script.sql'

 

2) If trying to run a SQLPlus script and passing the password encrypted through a PromptSet, please note:

Instead of using the encrypted password like this -

&UC_JOBMD CMD=Osql -q"...." --p-10131414234142144 --SFSU --U HIT

You will need to use a script variable as in the example below -

&UC_JOBMD CMD="&pw"

so your command would look something like this -

&UC_JOBMD CMD="&pw"

sqlplus &LOGIN#/${pass}&con_str# '@&script#' >> C:\temp\result.txt


evaluated withe a username of support, and a connection string of @supportdb, and a script of script.sql, this comes out to:

sqlplus support/[password]@supportdb '@script.sql'

Otherwise the Job ends with message similar to this:

The term 'CMD=echo --101FA2524FBB6A33CF...' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

At C:\UC4WA9\Agents\VWASUP03_WIN_01\TEMP\JAACUYQL.TXT.PS1:3 char:54

+ CMD="echo --101FA2524FBB6A33CF | ...." <<<<

+ CategoryInfo : ObjectNotFound: (CMD=echo --101F... -variable pass:String) [], CommandNotFoundException

+ FullyQualifiedErrorId : CommandNotFoundException