execute_hostcmd
Executes a host command across a set of targets.
Format
emcli execute_hostcmd
-cmd=<host_command"
-osscript=<script_to_be_executed>
-targets=<name1:type1;name2:type2;...>
-credential_set_name=<name>
[-input_file=<parameter_tag:script_file>]
[ ] indicates that the parameter is optionalOptions
-
cmd
Host_command can be any valid host command or group of host commands.
-
osscript
OS script to be executed with the cmd parameter.
-
targets
List of target-name, target-type pairs. The host command is executed across this list of Enterprise Manager targets. All targets must be of the type
hostorcomposite, which represents a group of targets. If it is a group, the group is expanded to extract all the host targets, and the host command is executed across these host targets. -
credential_set_name
The
credential_set_nameparameter refers to the set name of the preferred credentials stored in the Enterprise Manager repository. If this option is not present,HostCredsNormalis used for executing host commands. For thehosttarget type, two credential sets exist:-
HostCredsNormal— Default unprivileged credential set for a host target -
HostCredsPriv— Privileged credential set for a host targetThe credential set parameter can only be specified when the override credential parameters such as
usernameandpasswordare not present.If provided, the you must fully specify the override credential parameters. For host command,
usernameandpasswordmust be specified together.
-
-
input_file
Used in conjunction with
-osscript, this enables you to load the contents of an OS script. The-input_filespecifies a mapping between a tag and a local file path. The tag is specified in lieu of actual osscript contents of the-osscript. The tag must not contain colons ( : ) or semi-colons ( ; ).For information about the input_file parameter, see -input_file Syntax Guidelines.
Examples
Example 1
This example executes the host command ls -l; against the target stach.example.com:host and host targets contained in the group grp. The stored HostCredsPriv preferred credentials are used for all the targets.
emcli execute_hostcmd
-cmd="ls -l;"
-credential_set_name="HostCredsPriv"
-targets="stach.example.com:host;grp:composite"
Example 2
This example loads the contents of the script /scratch/dba_scripts/shellscript.sh into the value of -osscript and executes it against target reference.example.com:host and host targets contained in the group grp. The stored HostCredsNormal preferred credentials are used for all the targets.
emcli execute_hostcmd
-cmd="/bin/sh -s"
-osscript="FILE"
-input_file="FILE:/scratch/dba_scripts/shellscript.sh"
-credential_set_name="HostCredsNormal"
-targets="reference.example.com:host;grp:composite"