Chapter 1 Using the CLI
15
CLI commands can also be scripted using a
telnet
client like Expect or a Perl
library. Scripts can use interactive mode to execute single commands to emulate a
single-command mode
.
The following example shows the Perl Expect script
showfree.exp
that starts a
telnet
session, logs into the CLI, executes a command to show free disks, and
exits the CLI:
The following shows a possible result of executing this script:
#!/usr/bin/expect
set login [lindex $argv 1]
set password [lindex $argv 2]
set host [lindex $argv 3]
set command [lindex $argv 4]
spawn telnet $host
expect "Login:"
send "$login\r"
expect "Password:"
send "$password\r"
send "$command\r"
send "exit"
expect eof
$:./showfree.exp monitor !monitor 172.22.4.245 "show disks free"
Login: monitor
Password: ********
RPC-69501-001
System Name: Test
System Location: Lab
Version: W420B22
# show disks free
ID Serial# Vendor Rev. State Type Size(GB) Rate(Gb/s) SP
------------------------------------------------------------------------------
3 3KN0Z0BZ00007626NM4F SEAGATE 0003 AVAIL SAS 146 3.0
6 VDK41BT4CVLPNE ATA A9BA AVAIL SATA 250 3.0
7 3KN0Z6PD00007626NLV5 SEAGATE 0003 AVAIL SAS 146 1.5
10 3KN0Z09500007626NM28 SEAGATE 0003 AVAIL SAS 146 3.0
------------------------------------------------------------------------------
# exit
Summary of Contents for RPC12 Series
Page 1: ......
Page 11: ...12 Phoenix RPC12 Series CLI Reference Manual September 2008...
Page 29: ...30 Phoenix RPC12 Series CLI Reference Manual September 2008...
Page 35: ...36 Phoenix RPC12 Series CLI Reference Manual September 2008...
Page 227: ...228 Phoenix RPC12 Series CLI Reference Manual September 2008...