Contact Us
+1.831.460.7010

Question:  (by Syed)  Hi All, I am trying to issue " show ip route " to the CISCO or any devices cli prompt.  

Is there any method or API available in silvercreek to send CLI commands using tcl script?  

Please help me if any way to access remote CLI using ip address?

-Thanks,
Syed

Answer One:  (by Sandiyago) Since SilverCreek is a Tcl interpreter so I believe you can use whatever method (telnet, ssh ) available in Tcl language to connect to the remote server. For example, Telnet http://wiki.tcl.tk/684

 

You can consider using expect (http://www.nist.gov/el/msid/expect.cfm) to automate login that requires password, or set up public key authentication to avoid entering password (ssh)..

Answer Two:  (by Syed)  Whether the agent ip and telnet/ssh ip address should be same?

Answer Three: (by Sandiyago)  It may or may not be the same depending on the target that you are trying to log in, right? The IP address of telnet/ssh used in the script should be the same as that you would type in a shell.

Answer Four:  (by Syed)  When i try to execute ssh to the ip where the agent is running , i faced below error.

Please help me how to use "spawn" command?

[ERROR] Remarks: An error occurred during execution 
invalid command name "spawn" 
while executing 
"spawn ssh root@$ip"
(file"./testsuite/private-tests/chTest/testSNMP-TE-TNNL-PE-01.tcl"" line 7)
invoked from within 
"source $testfile"
Answer Five: (by Syed)  I need to execute the expect and spawn commands in silver creek?

 

#!/usr/bin/expect

set ip 172.23.130.134
set user "root"
set pwd "Welcome123"

spawn ssh root@$ip
expect {
-re ".*Are.*.*yes.*no.*" {
send "yes\r"
expect "password:"
send "$pwd\r"
expect "#"
}
"password:" {
send "$pwd\r"
expect "#"
}
}

Answer Six:  (by Sandiyago) Spawn is form Expect package, did you install Expect package?

If you are using SilverCreek's Tcl, place the Expect folder under the 'lib' directory. You can see other libraries like "snmptcl", "tkTable" there etc. Alternatively you can place Expect anywhere but update Tcl's "auto_path" so it can be found.

If you are using your own Tcl, then install it as Expect's installation instruction.  

The best approach is to use a standard Tcl, install Expect, and make sure it works then place it in your SilverCreek test.

Answer Seven:  (by Syed)  I have installed expect package in below path:

 

"C:\Tcl\lib\teapot\package\win32-ix86\lib\Expect5.43.2"

From tclsh ,

% puts $auto_path
C:/Tcl/lib/tcl8.5 C:/Tcl/lib c:/tcl/lib/teapot/package/win32-ix86/lib
c:/tcl/lib/teapot/package/tcl/lib example/example/
%

From Silver creek console , 

Console display active (Tcl8.4.14 / Tk8.4.14)
(SilverCreekMx) 49 % puts $auto_path
{C:/Program Files (x86)/InterWorkingLabs/SilverCreekMx/lib/tcl8.4} 
Files (x86)/InterWorkingLabs/SilverCreekMx/bin} {C:/Program Files 
(x86)/InterWorkingLabs/SilverCreekMx/lib/autoint} {C:/Program Files
(x86)/InterWorkingLabs/SilverCreekMx/lib/BWidget-1.4.1} {C:/Program Files
(x86)/InterWorkingLabs/SilverCreekMx/lib/compat} {C:/Program Files 
(x86)/InterWorkingLabs/SilverCreekMx/lib/gdi}{C:/Program Files 
(x86)/InterWorkingLabs/SilverCreekMx/lib/guilib} {C:/Program Files
(x86)/InterWorkingLabs/SilverCreekMx/lib/hdc} {C:/Program Files 
(x86)/InterWorkingLabs/SilverCreekMx/lib/mclistbox-1.02} {C:/Program 
Files (x86)/InterWorkingLabs/SilverCreekMx/lib/printer} {C:/Program Files
(x86)/InterWorkingLabs/SilverCreekMx/lib/scdb} {C:/Program Files 
(x86)/InterWorkingLabs/SilverCreekMx/lib/scgui} {C:/Program Files 
(x86)/InterWorkingLabs/SilverCreekMx/lib/scotty} {C:/Program Files
(x86)/InterWorkingLabs/SilverCreekMx/lib/sctest} {C:/Program Files 
(86)/InterWorkingLabs/SilverCreekMx/lib/snmptcl} {C:/Program Files
(x86)/InterWorkingLabs/SilverCreekMx/lib/snmptest} {C:/Program Files
(x86)/InterWorkingLabs/SilverCreekMx/lib/sscgui} {C:/Program Files 
(x86)/InterWorkingLabs/SilverCreekMx/lib/tablelist} {C:/Program Files 
(x86)/InterWorkingLabs/SilverCreekMx/lib/TCL8.3} {C:/Program Files
(x86)/InterWorkingLabs/SilverCreekMx/lib/tcl8.4} {C:/Program Files 
(x86)/InterWorkingLabs/SilverCreekMx/lib/timer} {C:/Program Files 
(x86)/InterWorkingLabs/SilverCreekMx/lib/TK8.3} {C:/Program Files
(x86)/InterWorkingLabs/SilverCreekMx/lib/tk8.4} {C:/Program Files 
(x86)/InterWorkingLabs/SilverCreekMx/lib/tkTable} {C:/Program Files 
(x86)/InterWorkingLabs/SilverCreekMx/lib/tools} {C:/Program Files
(x86)/InterWorkingLabs/SilverCreekMx/lib/tablelist/scripts},

How i need to add the expect path in to silvercreek auto_path???

Answer Eight:  (by Sandiyago)  In your script ./testsuite/private-tests/chTest/testSNMP-TE-TNNL-PE-01.tcl, try:

 

if {[lsearch $::auto_path
""C:/Tcl/lib/teapot/package/win32-ix86/lib"] == -
1} {
lappend ::auto_path "C:/Tcl/lib/teapot/package/win32-ix86/lib"
}
package require Expect

On Linux, try

if {[lsearch $::auto_path ""C:/usr/lib"] == -1} {
lappend ::auto_path "C:/usr/lib"
}
package require Expect

It should also work if you use "C:/Tcl/lib/teapot/package/win32-ix86/lib/Expect5.43.2", but I don't think that's necessary.