issuePcpuCommand
issuePcpuCommand - Execute a command on a list of ports
SYNOPSIS
issuePcpuCommand portList command
DESCRIPTION
The issuePcpuCommand command executes a Linux commands on a set of ports. The result of the command's execution indicates whether the command was sent to the ports or not. No indication is given that the ports actually ran successfully on the ports. The individual port by port result of the command can be retrieved by using the getFirst / getNext functions of pcpuCommandService.
ARGUMENTS
command
The text of the command to be executed, which must use an absolute path. For example, `/bin/ls'. No filename expansion is performed on the command; that is, `/bin/ls /bin/ix*' finds no matches. This, and the restriction on absolute path, may be avoided by executing the command through a bash shell, as in:
issuePcpuCommand portList "/bin/bash -c `ls -l /bin/ix*'"
portList
(By reference) The list of ports to execute command on, in one of the following formats:
one2oneArray, one2manyArray, many2oneArray, many2manyArray
Or a reference to a list. For example, pl after
set pl {{1 1 1} {1 1 2} {1 1 3} {1 1 4}} -or-
set pl {1,1,1 1,1,2 1,1,3 1,1,4}
RETURNS
0
The commands were sent to the ports.
1
The commands could not be sent to the ports.
EXAMPLES
set host techpubs-400
# Check if we're running on UNIX - connect to the TCL Server
# which must be running on the chassis
if [isUNIX] {
if [ixConnectToTclServer $host] {
ixPuts "Could not connect to $host"
return 1
}
}
package require IxTclServices
# Now connect to the chassis
if [ixConnectToChassis $host] {
ixPuts $::ixErrorInfo
return 1
}
set portList [list [list 1 1 1] [list 1 1 2]]
set ret [issuePcpuCommand portList "/bin/bash -c 'rm /tmp/hello'"]
ixPuts "Return is $ret"
for {set next [pcpuCommandService getFirst]} \
{$next != $::TCL_ERROR} \
{set next [pcpuCommandService getNext]} {
set chassis [pcpuCommandService cget -chassisID]
set card [pcpuCommandService cget -cardID]
set port [pcpuCommandService cget -portID]
set command [pcpuCommandService cget -command]
set output [pcpuCommandService cget -output]
set result [pcpuCommandService cget -result]
ixPuts "$chassis:$card:$port, cmd: $command, result: $result, output: $output"
}