Setting the user command prompt in the "Run SSH Command" operator
search cancel

Setting the user command prompt in the "Run SSH Command" operator

book

Article ID: 28747

calendar_today

Updated On:

Products

CA Process Automation Base

Issue/Introduction

Trying to run a process using the "Run SSH Command" operator may return errors like these:

The user command prompt cannot be empty

Unable to get the user prompt after login. [user@hostname ~]# ', which did not match prompt: '(.| )*[#]'

 

 

Environment

Release: ITPASA99000-4.1-Process Automation-Add On License for-CA Server Automation
Component:

Resolution

A simple ".*" in the user command prompt field will match anything returned from the user prompt, but if you need to get more specific than that, the syntax of the user command prompt field is very specific.

The SSH console displays this text when it's done to receive a command:

[<user>@<host> <current_folder>]$ 

For example:

[oracle@myserver ~]$ 

Notice that it is not the root user. If you are the root user, it will show "#" instead of "$", for example: [root@myserver ~]# 

The regular expression to match this string is:

((.|\n)*)@([a-zA-Z]{6})([db|DB]{2})([0-9]{2})(.*[$])

Where:

((.|\n)*) : Accepts anything, including word wrap (remember that after log in to the host via SSH for the first time, the console displays more information than only the text we've seen above);

@ : It must appears after the user name;

([a-zA-Z]{6})([db|DB]{2})([0-9]{2}) : You must change this part to validate your hostname or just replace it with your host name, like "myserver";

(.*[$]) : It accepts anything (except word wrap) until the special character "$" (if you're validating the root console, replace "$" for "#"). The folder you are in doesn't matter in this case;

Tip: You can test your RegEx here: regexr.com

See the example below:

One final note, notice in the example above there is a space between the expression and the closing quote.  This is to match up with the space after the prompt and before the cursor in the SSH console display.  If this space is missing, it will not match the prompt and the operator will fail.