RapidIdentity Product Guide: New UI

Command Line Interface (CLI) Actions

Open an SSH connection to a remote system.

Property

Value

Description

host*

text, expression, variable

the remote host name or address

port

expression, variable

the remote port (default: 22)

user*

text, expression, variable

the username for remote host

password*

password, string, expression, variable

the password for remote host

options

expression, variable

the value of the ciphers (allowed encryption algorithms), macs (allowed hashing algorithms), or whether to allow debugging to facilitate troubleshooting (debug: true)

returnVariable

expression, variable

name of the variable to be assigned to the return value

Example

session = openRemoteCLI("host1.acme.org", 22, "root","password")
close(session)

Open an SSH connection to a remote system using public/private key authentication.

Property

Value

Description

host*

text, expression, variable

the remote host name or address

port

expression, variable

the remote port (default: 22)

user*

text, expression, variable

the username for remote host

privateKey*

text, expression, variable

the path of the private key file within the project file store or the private key loaded as a byte array

publicKey

text, expression, variable

the path of the public key file within the project file store or the public key loaded as a byte array (default: none)

passPhrase

password, string, expression, variable

the passPhrase for private key (default: none)

options

expression, variable

the value of the ciphers (allowed encryption algorithms), macs (allowed hashing algorithms), or whether to allow debugging to provide more information to facilitate troubleshooting (debug: true)

returnVariable

expression, variable

name of the variable to be assigned to the return value

Example

# assumes public and private key have been uploaded to project 
    files store,
# and public key has been added as a trusted identity on SSH 
    remote server
session = openRemoteCLIWithCert("host1.acme.org", 22, "root", 
    "/.ssh/id_rsa", "/.ssh/id_rsa.pub", <Password>)
close(session)

Open a CLI connection to a remote Windows system.

Property

Value

Description

host*

text, expression, variable

the remote host name or address

user*

text, expression, variable

the username for remote host (must be an administrator)

domain*

text, expression, variable

the domain for the user

password*

password, string, expression, variable

the password for remote host

returnVariable

expression, variable

name of the variable to be assigned to the return value

Example

session = openRemoteWindowsCLI("windows.acme.org", "Administrator", 
    "ACME", <Password>)
close(session)

Quote a CLI command parameter so that no characters have special meaning to the CLI interpreter.

Property

Value

Description

param*

text, expression, variable

the command parameter to quote

method*

choice (cmd, powershell, sh), text, expression, variable

the cli quoting method

returnVariable

expression, variable

name of the variable to be assigned to the return value

Example

# open file with windows local users to create
varNewUsersInput = openDelimitedTextInput(newwindowslocalusers.csv, 
    "username, givenName, surname, password")
varSession = openRemoteWindowsCLI("windows.acme.org", "Administrator", 
    "ACME", <Password>)
close(session)
forEach(varNewUserRecord, newUsersInput) {
    # quote the dynamic data for use with powershell
    varQuotedUsername = quoteCLIParam(varNewUserRecord[\'username\'], 
        "powershell")
    varQuotedFullName = quoteCLIParam(varNewUserRecord[\'givenName\'] 
        + " " + varNewUserRecord[\'surname\'], "powershell")
    varQuotedPassword = quoteCLIParam(varNewUserRecord[\'username\'], 
        "powershell")
    # build the powershell command using the quoted data
    varPSCommand = "$Computer = [ADSI]\\"WinNT://$Env:COMPUTERNAME,
        Computer\\""
    varPSCommand = $varPSCommand + ";$LocalAdmin = $Computer.Create
        (\'User\" + varQuotedUsername + ")"
    varPSCommand = $varPSCommand + ";$LocalAdmin.SetPassword
        (" + varQuotedPassword + ")"\n varPSCommand = $varPSCommand +  
         ";$LocalAdmin.SetFullName(" + varQuotedQuotedFullname + ")"
        varPSCommand = varPSCommand + ";$LocalAdmin.UserFlags = 64 + 65536"
        varPSCommand = varPSCommand + ";$LocalAdmin.SetInfo()"
        # quote the entire powershell command for cmd
        varQuotedPSCommand = quoteCLIParam(varPSCommand, "cmd")
        runRemoteCLICommand(varSession, "powershell -command " +        
            varQuotedPSCommand)
}
close(varSession)
close(varNewUsersInput)

Run a CLI command. Returns a record with 3 fields: exitStatus, output, and error.

Property

Value

Description

command*

text, expression, variable

the command to run

input

text, expression, variable

a string to feed to the command as standard input (default: none)

env

expression, variable

a Record containing environment variables to set (default: none)

returnVariable

expression, variable

name of the variable to be assigned to the return value

Example

result = runCLICommand("date")
# Should return current date/time
log(, u"result['output']", )

Run a CLI command on a remote system. Returns a record with 3 fields: exitStatus, output, and error.

Property

Value

Description

remoteCLI*

expression, variable

the remote CLI connection

command*

text, expression, variable

the command to run.

input

text, expression, variable

a string to feed to the command as standard input (default: none)

env

expression, variable

a Record containing environment variables to set (default: none)

returnVariable

expression, variable

name of the variable to be assigned to the return value

Example

session = openRemoteCLI("host1.acme.org","root","password")
result = runRemoteCLICommand(session,"date")
close(session)
# Should return current date/time
log(, u"result['output']", )