OBJECTIVE:
This is a tutorial on how to get Expect to run on windows.
The steps are shown below. This is for those who installed a version of
activetcl that is above 8.4.9.X.Expect might not be installed by default.If you installed activetcl version 8.4.9.16 you have expect installed by default.The download link can be found here:
http://www.activestate.com/activetcl/downloads
STEPS
1. Download ActiveTcl here http://www.activestate.com/activetcl/downloads
2. After installing which is pretty straight forward,configure your environmental variable path to point to :C:\Tcl\bin(or your install directory/bin)
3. Expect might not be installed by default so in the command line run :
> teacup install Expect
4. if you want to see other commands related to teacup use the "teacup help"
C:\temp>teacup help
teacup.exe
is a tool to access package repositories
teacup.exe help cmds-by-group Grouped list of commands provided by tea
cup
teacup.exe help commands Alphabetical list of commands provided b
y teacup
teacup.exe help help How to use help
teacup.exe help options Describes the standard options
teacup.exe help queries Describe the syntax of complex queries
C:\temp>teacup help commands
commands -- Alphabetical list of commands provided by teacup
Use 'help <commandname>' to get detailed help for a command.
teacup.exe archive Manage archives
teacup.exe cache Manage cache settings
teacup.exe create Create installation repository
teacup.exe default Manage installation repository
teacup.exe delete Delete installation repository
teacup.exe describe Describe package found in an archive
teacup.exe get Get archive file of package found in an archive
teacup.exe install Get and install a package found in an archive or file
teacup.exe keys List meta data keys found in the archives
teacup.exe link Manage links between installation repositories and tc
l shells
teacup.exe list List packages found in the archives
teacup.exe log Manage the log of installed/removed packages
teacup.exe profiles Find and list profile packages found in the archives
teacup.exe proxy Manage proxying
teacup.exe regenerate Recreate broken toplevel pkgIndex.tcl files
teacup.exe remove Remove installed packages
teacup.exe search Search and list packages using complex queries
teacup.exe setup Enable tcl shells to handle installation repositories
teacup.exe timeout Manage timeout
teacup.exe update Update local repository from the archives.
teacup.exe update-self Get newest revision of teacup.exe for the platform
teacup.exe version Print version of teacup.exe
teacup.exe verify Check a repository for problems.
teacup.exe who Print description of teacup.exe
C:\temp>
This is a tutorial on how to get Expect to run on windows.
The steps are shown below. This is for those who installed a version of
activetcl that is above 8.4.9.X.Expect might not be installed by default.If you installed activetcl version 8.4.9.16 you have expect installed by default.The download link can be found here:
http://www.activestate.com/activetcl/downloads
STEPS
1. Download ActiveTcl here http://www.activestate.com/activetcl/downloads
2. After installing which is pretty straight forward,configure your environmental variable path to point to :C:\Tcl\bin(or your install directory/bin)
3. Expect might not be installed by default so in the command line run :
> teacup install Expect
4. if you want to see other commands related to teacup use the "teacup help"
C:\temp>teacup help
teacup.exe
is a tool to access package repositories
teacup.exe help cmds-by-group Grouped list of commands provided by tea
cup
teacup.exe help commands Alphabetical list of commands provided b
y teacup
teacup.exe help help How to use help
teacup.exe help options Describes the standard options
teacup.exe help queries Describe the syntax of complex queries
C:\temp>teacup help commands
commands -- Alphabetical list of commands provided by teacup
Use 'help <commandname>' to get detailed help for a command.
teacup.exe archive Manage archives
teacup.exe cache Manage cache settings
teacup.exe create Create installation repository
teacup.exe default Manage installation repository
teacup.exe delete Delete installation repository
teacup.exe describe Describe package found in an archive
teacup.exe get Get archive file of package found in an archive
teacup.exe install Get and install a package found in an archive or file
teacup.exe keys List meta data keys found in the archives
teacup.exe link Manage links between installation repositories and tc
l shells
teacup.exe list List packages found in the archives
teacup.exe log Manage the log of installed/removed packages
teacup.exe profiles Find and list profile packages found in the archives
teacup.exe proxy Manage proxying
teacup.exe regenerate Recreate broken toplevel pkgIndex.tcl files
teacup.exe remove Remove installed packages
teacup.exe search Search and list packages using complex queries
teacup.exe setup Enable tcl shells to handle installation repositories
teacup.exe timeout Manage timeout
teacup.exe update Update local repository from the archives.
teacup.exe update-self Get newest revision of teacup.exe for the platform
teacup.exe version Print version of teacup.exe
teacup.exe verify Check a repository for problems.
teacup.exe who Print description of teacup.exe
C:\temp>
OTHERS
you can learn a lot also by looking at the demo application of tcl/tk and the source code related to it. Here is some screenshot about how you can access the demos directory and see demos source codes.
Expect script example
We will use an expect script to telnet to a router in GNS3 but you can do it with a real router if you want.You just need to turn on a router and check its console port number and telnet to it using "telnet 127.0.0.1 <console number>" to get access to the GNS3 router .
The script we will use to access the router and check its loopback config.
------ test.tcl
package require Expect
spawn telnet 127.0.0.1 2001
expect "#" { exp_send "\r"}
expect "#" { exp_send "sh run int lo0\r"}
expect "#" { exp_send "\r" }
exit
-------
Now lets run the expect script to check it
done