


 



<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://docwiki.cisco.com/w/skins/common/feed.css?270"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://docwiki.cisco.com/w/index.php?title=Remote_VTY_Command_Script&amp;feed=atom&amp;action=history</id>
		<title>Remote VTY Command Script - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://docwiki.cisco.com/w/index.php?title=Remote_VTY_Command_Script&amp;feed=atom&amp;action=history"/>
		<link rel="alternate" type="text/html" href="http://docwiki.cisco.com/w/index.php?title=Remote_VTY_Command_Script&amp;action=history"/>
		<updated>2013-05-19T12:06:48Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.16.0</generator>

	<entry>
		<id>http://docwiki.cisco.com/w/index.php?title=Remote_VTY_Command_Script&amp;diff=44794&amp;oldid=prev</id>
		<title>Jkratky at 17:11, 22 February 2012</title>
		<link rel="alternate" type="text/html" href="http://docwiki.cisco.com/w/index.php?title=Remote_VTY_Command_Script&amp;diff=44794&amp;oldid=prev"/>
				<updated>2012-02-22T17:11:32Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 17:11, 22 February 2012&lt;/td&gt;
		&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Technologies]]&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Category:Network Management]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Category:Network Management]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Category:Network Management and Automation]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Category:Network Management and Automation]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Jkratky</name></author>	</entry>

	<entry>
		<id>http://docwiki.cisco.com/w/index.php?title=Remote_VTY_Command_Script&amp;diff=40953&amp;oldid=prev</id>
		<title>Pzimmerm: added categories</title>
		<link rel="alternate" type="text/html" href="http://docwiki.cisco.com/w/index.php?title=Remote_VTY_Command_Script&amp;diff=40953&amp;oldid=prev"/>
				<updated>2011-06-01T20:46:30Z</updated>
		
		<summary type="html">&lt;p&gt;added categories&lt;/p&gt;
&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 20:46, 1 June 2011&lt;/td&gt;
		&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Category:Technologies]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Category:Technologies]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Category:Network Management]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Category:Network Management]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[[Category:Network Management and Automation]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;__TOC__&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;__TOC__&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Pzimmerm</name></author>	</entry>

	<entry>
		<id>http://docwiki.cisco.com/w/index.php?title=Remote_VTY_Command_Script&amp;diff=37861&amp;oldid=prev</id>
		<title>Sergio.zavala@sidetec.com.mx: /* Script source */</title>
		<link rel="alternate" type="text/html" href="http://docwiki.cisco.com/w/index.php?title=Remote_VTY_Command_Script&amp;diff=37861&amp;oldid=prev"/>
				<updated>2011-01-28T23:08:24Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Script source&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 23:08, 28 January 2011&lt;/td&gt;
		&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 344:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 344:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; # connect and check return status before proceeding&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; # connect and check return status before proceeding&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; if { [Connect &amp;quot;$method&amp;quot; &amp;quot;$hostname&amp;quot; &amp;quot;$username&amp;quot; &amp;quot;$password&amp;quot;] &amp;gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;=&lt;/del&gt;0 } {&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; if { [Connect &amp;quot;$method&amp;quot; &amp;quot;$hostname&amp;quot; &amp;quot;$username&amp;quot; &amp;quot;$password&amp;quot;] &amp;gt; 0 } {&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;  # stop here,&amp;nbsp; no need to print an error since Connect func does that&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;  # stop here,&amp;nbsp; no need to print an error since Connect func does that&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;  exit 1&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;  exit 1&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Sergio.zavala@sidetec.com.mx</name></author>	</entry>

	<entry>
		<id>http://docwiki.cisco.com/w/index.php?title=Remote_VTY_Command_Script&amp;diff=36910&amp;oldid=prev</id>
		<title>Sergio.zavala@sidetec.com.mx: /* Script source */</title>
		<link rel="alternate" type="text/html" href="http://docwiki.cisco.com/w/index.php?title=Remote_VTY_Command_Script&amp;diff=36910&amp;oldid=prev"/>
				<updated>2011-01-10T20:38:44Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Script source&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 20:38, 10 January 2011&lt;/td&gt;
		&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 88:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 88:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;#&amp;nbsp;  Tim Evens	5/21/09	Initial program created&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;#&amp;nbsp;  Tim Evens	5/21/09	Initial program created&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;#&amp;nbsp;  Sergio Zavala	12/26/10 Connection return code corrected &amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;#&amp;nbsp;  Sergio Zavala	12/26/10 Connection return code corrected &amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;#&amp;nbsp;  Tim Evens	1/05/10	Connection validated&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;##########################################################################&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;##########################################################################&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 341:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 342:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;  close $cmdfile_fd&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;  close $cmdfile_fd&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;nbsp;  }&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; # Connect to the host and login -- Tim Evens&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; # Connect &amp;quot;$method&amp;quot; &amp;quot;$hostname&amp;quot; &amp;quot;$username&amp;quot; &amp;quot;$password&amp;quot;&amp;nbsp;  &lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; # &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Connect to the host and login &lt;/del&gt;and &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;assign the &lt;/del&gt;return &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;value -- Sergio Zavala&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; # &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;connect &lt;/ins&gt;and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;check &lt;/ins&gt;return &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;status before proceeding&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;set rval &lt;/del&gt;[Connect &amp;quot;$method&amp;quot; &amp;quot;$hostname&amp;quot; &amp;quot;$username&amp;quot; &amp;quot;$password&amp;quot;]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;if { &lt;/ins&gt;[Connect &amp;quot;$method&amp;quot; &amp;quot;$hostname&amp;quot; &amp;quot;$username&amp;quot; &amp;quot;$password&amp;quot;] &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;gt;=0 } {&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;  # stop here,&amp;nbsp; no need to print an error since Connect func does that&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;  exit 1&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; # Validate connection again -- Sergio Zavala&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;nbsp;  if { $rval &amp;lt;= 0 } {&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; # If we have an enable password, lets try to send it&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; # If we have an enable password, lets try to send it&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Sergio.zavala@sidetec.com.mx</name></author>	</entry>

	<entry>
		<id>http://docwiki.cisco.com/w/index.php?title=Remote_VTY_Command_Script&amp;diff=36702&amp;oldid=prev</id>
		<title>Sergio.zavala@sidetec.com.mx: /* Script source */</title>
		<link rel="alternate" type="text/html" href="http://docwiki.cisco.com/w/index.php?title=Remote_VTY_Command_Script&amp;diff=36702&amp;oldid=prev"/>
				<updated>2010-12-27T05:36:43Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Script source&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 05:36, 27 December 2010&lt;/td&gt;
		&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 81:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 81:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;#&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;#&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;# Created by Tim Evens (tim@evensweb.com), 5/2009&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;# Created by Tim Evens (tim@evensweb.com), 5/2009&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;# Corrected by Sergio Zavala (sergio.zavala at sidetec.com.mx), 12/2010&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;#&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;# Copyright Tim Evens, 2009&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;# Copyright Tim Evens, 2009&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;#&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;#&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;# HISTORY:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;# HISTORY:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;#&amp;nbsp;  Tim Evens	5/21/09	Initial program created&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;#&amp;nbsp;  Tim Evens	5/21/09	Initial program created&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;#&amp;nbsp;  Sergio Zavala	12/26/10 Connection return code corrected &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;##########################################################################&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;##########################################################################&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 338:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 341:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;  close $cmdfile_fd&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;  close $cmdfile_fd&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;nbsp;  }&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; # Connect to the host and login&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; # Connect to the host and login &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;-- Tim Evens&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; Connect &amp;quot;$method&amp;quot; &amp;quot;$hostname&amp;quot; &amp;quot;$username&amp;quot; &amp;quot;$password&amp;quot;&amp;nbsp;  &amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;# &lt;/ins&gt;Connect &amp;quot;$method&amp;quot; &amp;quot;$hostname&amp;quot; &amp;quot;$username&amp;quot; &amp;quot;$password&amp;quot;&amp;nbsp;  &amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; # Connect to the host and login and assign the return value -- Sergio Zavala&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; set rval [Connect &amp;quot;$method&amp;quot; &amp;quot;$hostname&amp;quot; &amp;quot;$username&amp;quot; &amp;quot;$password&amp;quot;]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; # Validate connection again -- Sergio Zavala&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;nbsp;  if { $rval &amp;lt;= 0 } {&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; # If we have an enable password, lets try to send it&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; # If we have an enable password, lets try to send it&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 409:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 418:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;## END OF SCRIPT #############################################################&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;## END OF SCRIPT #############################################################&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt; &amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== Examples ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== Examples ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Sergio.zavala@sidetec.com.mx</name></author>	</entry>

	<entry>
		<id>http://docwiki.cisco.com/w/index.php?title=Remote_VTY_Command_Script&amp;diff=22204&amp;oldid=prev</id>
		<title>Tievens: Script for automating remote CLI commands via TELENT and SSH</title>
		<link rel="alternate" type="text/html" href="http://docwiki.cisco.com/w/index.php?title=Remote_VTY_Command_Script&amp;diff=22204&amp;oldid=prev"/>
				<updated>2009-11-18T17:54:49Z</updated>
		
		<summary type="html">&lt;p&gt;Script for automating remote CLI commands via TELENT and SSH&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category:Technologies]]&lt;br /&gt;
[[Category:Network Management]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Remote VTY Command Script==&lt;br /&gt;
Running one or more interactive CLI commands is a common task in network management.  Having a script to automate this task becomes a critical tool. &lt;br /&gt;
&lt;br /&gt;
This script automates interactive TELNET or SSH sessions.  Any command that can be issued in CLI can be issued via the VTY run command script in an automated fashion.  Below are some example uses: &lt;br /&gt;
&lt;br /&gt;
* Run a set of commands on hundreds of devices&lt;br /&gt;
* Configuration changes&lt;br /&gt;
* Archive configurations and software&lt;br /&gt;
* Audits, inventory and discovery &lt;br /&gt;
* Automated troubleshooting&lt;br /&gt;
&lt;br /&gt;
==Requirements==&lt;br /&gt;
This script is written in Expect.  A current version of Expect is required.  Expect and installation requirements for Expect can be found at [http://expect.nist.gov Expect Homepage]&lt;br /&gt;
&lt;br /&gt;
Tested on RHEL 5 running expect 5.43.0-5.1 and Mac OS X 10.6 running Expect 5.44.1.11.   &lt;br /&gt;
&lt;br /&gt;
The script is platform independent and should run on any platform that can run Expect.  &lt;br /&gt;
&lt;br /&gt;
==VTY Run Command Script==&lt;br /&gt;
The script supports command line options for configuration.  Below is a list of the command line options available:&lt;br /&gt;
&lt;br /&gt;
{{note|Run the script using '''vty_runcmd.exp &amp;lt;options&amp;gt;'''}}&lt;br /&gt;
&lt;br /&gt;
====Required Options====&lt;br /&gt;
{|&lt;br /&gt;
  ! align=&amp;quot;left&amp;quot; | Option&lt;br /&gt;
  ! align=&amp;quot;left&amp;quot; | Option Value&lt;br /&gt;
  ! align=&amp;quot;left&amp;quot; | Description&lt;br /&gt;
  |-&lt;br /&gt;
  | -h || Hostname or IP || Enter the hostname or IP address of the device to run the remote command on&lt;br /&gt;
  |-&lt;br /&gt;
  | -u || username || Enter the username for login or username prompt, normally required for Unix or AAA logins.  Use none if no login/username required &lt;br /&gt;
  |-&lt;br /&gt;
  | -p || password || Enter the password for the firs login/username prompt.  This is the first password, non enable mode&lt;br /&gt;
  |-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
====Optional Options====&lt;br /&gt;
{|&lt;br /&gt;
  ! align=&amp;quot;left&amp;quot; | Option&lt;br /&gt;
  ! align=&amp;quot;left&amp;quot; | Option Value&lt;br /&gt;
  ! align=&amp;quot;left&amp;quot; | Description&lt;br /&gt;
  |-&lt;br /&gt;
  | -e || password || Enter the enable password or secret.  This is to enter enable mode.&lt;br /&gt;
  |-&lt;br /&gt;
  | -t || seconds || Enter the timeout for expect wait in seconds &lt;br /&gt;
  |-&lt;br /&gt;
  | -m || ssh or telnet || Enter '''ssh''' or '''telnet''' for connection method.  TELNET is the default.  For SSH, the script will automatically enter '''yes''' for authorized host entries.&lt;br /&gt;
  |-&lt;br /&gt;
  | -f || filename || Enter the filename to use as the command file.  Default is to use STDIN&lt;br /&gt;
  |-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Automating script to run on multiple hosts ===&lt;br /&gt;
See [[Automated Remote VTY Command Script]] for more details on how to run the script via '''cron''' and how to run it in a loop fashion for multiple hosts. &lt;br /&gt;
&lt;br /&gt;
=== Steps to install the script ===&lt;br /&gt;
&lt;br /&gt;
# Cut and paste the below script into a text file named '''vty_runcmd.exp'''&lt;br /&gt;
# Edit the first line of the script and update the &amp;quot;'''#!/usr/bin/expect --'''&amp;quot; command to point to your installed '''expect''' binary &lt;br /&gt;
# (Unix,Linux,Mac OS only) change the mode so that the script will run by using &amp;quot;'''chmod 755 vty_runcmd.exp'''&amp;quot;&lt;br /&gt;
# Run the script by using &amp;quot;'''./vty_runcmd.exp &amp;lt;options&amp;gt;'''&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Script source====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/expect --&lt;br /&gt;
##########################################################################&lt;br /&gt;
# vty_runcmd.exp&lt;br /&gt;
# &lt;br /&gt;
#    This is an expect script that will connect to a device using ssh or&lt;br /&gt;
#    telnet, then run the specified command.  The output will either be &lt;br /&gt;
#    written to an output file or printed to stdout.&lt;br /&gt;
#&lt;br /&gt;
# Created by Tim Evens (tim@evensweb.com), 5/2009&lt;br /&gt;
# Copyright Tim Evens, 2009&lt;br /&gt;
#&lt;br /&gt;
# HISTORY:&lt;br /&gt;
#   Tim Evens	5/21/09	Initial program created&lt;br /&gt;
##########################################################################&lt;br /&gt;
&lt;br /&gt;
#++++++++++++++++++++++++++&lt;br /&gt;
# Global vars&lt;br /&gt;
#++++++++++++++++++++++++++&lt;br /&gt;
set timeout 30&lt;br /&gt;
# below matches prompts such as &amp;quot;router#&amp;quot;, &amp;quot;router&amp;gt;&amp;quot;, &amp;quot;router$&amp;quot;&lt;br /&gt;
set prompt &amp;quot;\&amp;gt;\ *$|#\ *$|\\$\ *$&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#-----------------------------------------------&lt;br /&gt;
# Connect(method, prompt, host, user, password)&lt;br /&gt;
#    This function will connect to a host using telnet or ssh.&lt;br /&gt;
# &lt;br /&gt;
# RETURNS:&lt;br /&gt;
#    zero if successful&lt;br /&gt;
#    1 = timeout or invalid hostname or method&lt;br /&gt;
#    2 = invalid login&lt;br /&gt;
#    3 = timeout waiting for login&lt;br /&gt;
#    4 = connection failed to host during expect wait&lt;br /&gt;
#    9 = unknown error&lt;br /&gt;
#-----------------------------------------------&lt;br /&gt;
proc Connect {method host usr pw} {&lt;br /&gt;
   set rval 0&lt;br /&gt;
   set usr_chk 0&lt;br /&gt;
   set pw_chk 0&lt;br /&gt;
   set max_checks 4&lt;br /&gt;
   global spawn_id&lt;br /&gt;
   global timeout&lt;br /&gt;
   global prompt&lt;br /&gt;
  &lt;br /&gt;
   puts &amp;quot;Connecting using $method to $host as user $usr&amp;quot;&lt;br /&gt;
   &lt;br /&gt;
   # see if we are using ssh&lt;br /&gt;
   if { [string compare $method &amp;quot;ssh&amp;quot;] == 0 } {&lt;br /&gt;
      set host &amp;quot;$usr@$host&amp;quot;&lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
   # Run command and get connected&lt;br /&gt;
   set id [spawn $method $host]&lt;br /&gt;
   if { $id &amp;lt;= 0 } {&lt;br /&gt;
      puts &amp;quot;ERROR: Failed to connect to host\n&amp;quot;&lt;br /&gt;
      set rval 1&lt;br /&gt;
      &lt;br /&gt;
   } else {&lt;br /&gt;
      puts &amp;quot;Using Process ID: $id&amp;quot;&lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
   # Start the expect/send process to login&lt;br /&gt;
   expect {&lt;br /&gt;
   &lt;br /&gt;
      # Below handles the username prompt&lt;br /&gt;
      -nocase -re &amp;quot;name:|^login:&amp;quot; {&lt;br /&gt;
         send &amp;quot;$usr\r&amp;quot;&lt;br /&gt;
         incr usr_chk;&lt;br /&gt;
         &lt;br /&gt;
         # continue with expect loop as long as we haven't hit this too many times         &lt;br /&gt;
         if { $usr_chk &amp;lt; $max_checks } {&lt;br /&gt;
            exp_continue&lt;br /&gt;
         } else {&lt;br /&gt;
            set rval 2&lt;br /&gt;
            puts &amp;quot;ERROR: Login retry failed.  Invalid login username&amp;quot;&lt;br /&gt;
         }   &lt;br /&gt;
&lt;br /&gt;
       # Below handles the password prompt&lt;br /&gt;
       } -nocase -re &amp;quot;word:&amp;quot; {&lt;br /&gt;
         send &amp;quot;$pw\r&amp;quot;&lt;br /&gt;
         incr pw_chk;&lt;br /&gt;
         &lt;br /&gt;
         # continue with expect loop as long as we haven't hit this too many times&lt;br /&gt;
         if { $pw_chk &amp;lt; $max_checks } {&lt;br /&gt;
            exp_continue        &lt;br /&gt;
         } else {&lt;br /&gt;
            set rval 2&lt;br /&gt;
            puts &amp;quot;ERROR: Login retry failed.  Invalid login password&amp;quot;&lt;br /&gt;
         }   &lt;br /&gt;
         &lt;br /&gt;
      # Below handles the yes/no prompt when SSH first connects to a host   &lt;br /&gt;
      } -nocase -re &amp;quot;\(yes/no\)&amp;quot; {&lt;br /&gt;
         send &amp;quot;yes\r&amp;quot;&lt;br /&gt;
         exp_continue&lt;br /&gt;
      &lt;br /&gt;
      # Below handles the normal prompt to detect when logged in&lt;br /&gt;
      } -nocase -re &amp;quot;$prompt&amp;quot; {&lt;br /&gt;
         puts &amp;quot;\nSUCCESS: Logged in and ready to send commands\n&amp;quot;&lt;br /&gt;
&lt;br /&gt;
      # Below is for expect timeout waiting for a                                 &lt;br /&gt;
      } timeout {&lt;br /&gt;
         puts &amp;quot;ERROR: Connection timeout waiting for login prompt&amp;quot;&lt;br /&gt;
         set rval 3&lt;br /&gt;
      &lt;br /&gt;
      # Below is for when the connect is closed before finishing   &lt;br /&gt;
      } eof {&lt;br /&gt;
         puts &amp;quot;ERROR: Connection to host failed: $expect_out(buffer)&amp;quot;&lt;br /&gt;
         set rval 4&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
     &lt;br /&gt;
   # return with error code&lt;br /&gt;
   return $rval&lt;br /&gt;
} &lt;br /&gt;
# End of Connect ()&lt;br /&gt;
&lt;br /&gt;
#-----------------------------------------------&lt;br /&gt;
# Usage()&lt;br /&gt;
#     This function will print the usage&lt;br /&gt;
#-----------------------------------------------&lt;br /&gt;
proc Usage {} {&lt;br /&gt;
&lt;br /&gt;
   puts &amp;quot;Usage: vty_runcmd.exp &amp;lt;options&amp;gt;&amp;quot;&lt;br /&gt;
   puts &amp;quot;\n&amp;quot;&lt;br /&gt;
   puts &amp;quot;REQUIRED OPTIONS:&amp;quot;&lt;br /&gt;
   puts &amp;quot;   -h &amp;lt;hostname|ip&amp;gt;   = hostname or ip address&amp;quot;&lt;br /&gt;
   puts &amp;quot;   -u &amp;lt;username&amp;gt;      = username to login with&amp;quot;&lt;br /&gt;
   puts &amp;quot;   -p &amp;lt;password&amp;gt;      = password for login&amp;quot;&lt;br /&gt;
   puts &amp;quot;\n&amp;quot;&lt;br /&gt;
   puts &amp;quot;Other OPTIONS:&amp;quot;&lt;br /&gt;
   puts &amp;quot;   -e &amp;lt;enable password&amp;gt; = Enable password&amp;quot;&lt;br /&gt;
   puts &amp;quot;   -t &amp;lt;seconds&amp;gt;         = timeout in seconds&amp;quot;&lt;br /&gt;
   puts &amp;quot;   -m &amp;lt;ssh|telnet&amp;gt;      = use either ssh or telnet, default telnet&amp;quot;&lt;br /&gt;
   puts &amp;quot;   -f &amp;lt;filename&amp;gt;        = command file, defaults to STDIN&amp;quot;&lt;br /&gt;
   puts &amp;quot;\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
# End of Check_ARGS()&lt;br /&gt;
&lt;br /&gt;
#-----------------------------------------------&lt;br /&gt;
# main() &lt;br /&gt;
# &lt;br /&gt;
# RETURNS:&lt;br /&gt;
#    0 if successful&lt;br /&gt;
#    1 if invalid arg passed&lt;br /&gt;
#    2 not enough args (required args not met)&lt;br /&gt;
#-----------------------------------------------&lt;br /&gt;
   set rval 0&lt;br /&gt;
   set hostname &amp;quot;&amp;quot;&lt;br /&gt;
   set username &amp;quot;&amp;quot;&lt;br /&gt;
   set password &amp;quot;&amp;quot;&lt;br /&gt;
   set enable_pw &amp;quot;&amp;quot;&lt;br /&gt;
   set cmdfile &amp;quot;&amp;quot;&lt;br /&gt;
   set method &amp;quot;telnet&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   # Loop through the command line args   &lt;br /&gt;
   for {set n 0} {$n &amp;lt; $argc} {incr n} {&lt;br /&gt;
   &lt;br /&gt;
      set arg [lindex $argv $n]&lt;br /&gt;
      &lt;br /&gt;
      # Check the args&lt;br /&gt;
      if { [string compare $arg &amp;quot;-u&amp;quot;] == 0} {&lt;br /&gt;
         if { $n &amp;lt; $n+1 } {&lt;br /&gt;
            incr n&lt;br /&gt;
            set username [lindex $argv $n]&lt;br /&gt;
         } else {&lt;br /&gt;
            set rval 1&lt;br /&gt;
            puts &amp;quot;ERROR: Missing ARG for $arg\n&amp;quot;&lt;br /&gt;
         }&lt;br /&gt;
    &lt;br /&gt;
      } elseif { [string compare $arg &amp;quot;-p&amp;quot;] == 0} {&lt;br /&gt;
         if { $n &amp;lt; $n+1 } {&lt;br /&gt;
            incr n&lt;br /&gt;
            set password [lindex $argv $n]&lt;br /&gt;
         } else {&lt;br /&gt;
            set rval 1&lt;br /&gt;
            puts &amp;quot;ERROR: Missing ARG for $arg\n&amp;quot;&lt;br /&gt;
         }&lt;br /&gt;
         &lt;br /&gt;
      } elseif { [string compare $arg &amp;quot;-h&amp;quot;] == 0} {&lt;br /&gt;
         if { $n &amp;lt; $n+1 } {&lt;br /&gt;
            incr n&lt;br /&gt;
            set hostname [lindex $argv $n]&lt;br /&gt;
         } else {&lt;br /&gt;
            set rval 1&lt;br /&gt;
            puts &amp;quot;ERROR: Missing ARG for $arg\n&amp;quot;&lt;br /&gt;
         }&lt;br /&gt;
&lt;br /&gt;
      } elseif { [string compare $arg &amp;quot;-m&amp;quot;] == 0} {&lt;br /&gt;
         if { $n &amp;lt; $n+1 } {&lt;br /&gt;
            incr n&lt;br /&gt;
            set method [lindex $argv $n]&lt;br /&gt;
&lt;br /&gt;
         } else {&lt;br /&gt;
            set rval 1&lt;br /&gt;
            puts &amp;quot;ERROR: Missing ARG for $arg\n&amp;quot;&lt;br /&gt;
         }&lt;br /&gt;
         &lt;br /&gt;
      } elseif { [string compare $arg &amp;quot;-t&amp;quot;] == 0} {&lt;br /&gt;
         if { $n &amp;lt; $n+1 } {&lt;br /&gt;
            incr n&lt;br /&gt;
            set timeout [lindex $argv $n]&lt;br /&gt;
         } else {&lt;br /&gt;
            set rval 1&lt;br /&gt;
            puts &amp;quot;ERROR: Missing ARG for $arg\n&amp;quot;&lt;br /&gt;
         }&lt;br /&gt;
 &lt;br /&gt;
      } elseif { [string compare $arg &amp;quot;-f&amp;quot;] == 0} {&lt;br /&gt;
         if { $n &amp;lt; $n+1 } {&lt;br /&gt;
            incr n&lt;br /&gt;
            set cmdfile [lindex $argv $n]&lt;br /&gt;
         } else {&lt;br /&gt;
            set rval 1&lt;br /&gt;
            puts &amp;quot;ERROR: Missing ARG for $arg\n&amp;quot;&lt;br /&gt;
         }&lt;br /&gt;
         &lt;br /&gt;
      } elseif { [string compare $arg &amp;quot;-e&amp;quot;] == 0} {&lt;br /&gt;
         if { $n &amp;lt; $n+1 } {&lt;br /&gt;
            incr n&lt;br /&gt;
            set enable_pw [lindex $argv $n]&lt;br /&gt;
         } else {&lt;br /&gt;
            set rval 1&lt;br /&gt;
            puts &amp;quot;ERROR: Missing ARG for $arg\n&amp;quot;&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
   # End of arg check&lt;br /&gt;
        &lt;br /&gt;
   # make sure we found the amount of args expected   &lt;br /&gt;
   if { [llength $hostname] &amp;gt; 0 &amp;amp;&amp;amp; [llength $method] &amp;gt; 0 &amp;amp;&amp;amp; &lt;br /&gt;
          [llength $username] &amp;gt; 0 &amp;amp;&amp;amp; [llength $password] &amp;gt; 0 } {&lt;br /&gt;
      # Print out the args found&lt;br /&gt;
      puts &amp;quot;hostname = $hostname, user = $username, pw = $password, method = $method&amp;quot;&lt;br /&gt;
      &lt;br /&gt;
   } else {&lt;br /&gt;
      set rval 2&lt;br /&gt;
      puts &amp;quot;ERROR: Missing required args, must have -h, -u, -p\n&amp;quot;&lt;br /&gt;
      Usage&lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
   # ------------------&lt;br /&gt;
   # Now that we have the correct ARGS and we know what to do, lets proceed to&lt;br /&gt;
   #     connect, run the commands, then exit.&lt;br /&gt;
   # ------------------&lt;br /&gt;
   &lt;br /&gt;
   # make sure we have not encountered any errors&lt;br /&gt;
   if { $rval &amp;lt;= 0 } {&lt;br /&gt;
   &lt;br /&gt;
      if { [llength $cmdfile] &amp;lt;= 0 } {&lt;br /&gt;
         puts &amp;quot;Enter the send text (type 'end' on last line to finish):&amp;quot;&lt;br /&gt;
         expect_user -nocase -re &amp;quot;(.*)\nend\n&amp;quot;&lt;br /&gt;
         set send_text $expect_out(1,string)&lt;br /&gt;
         &lt;br /&gt;
      } else {&lt;br /&gt;
         puts &amp;quot;Using $cmdfile for send text&amp;quot;&lt;br /&gt;
         # set cmdfile_fd [open $cmdfile r]&lt;br /&gt;
         if { [catch {set cmdfile_fd [open $cmdfile r]} err_msg] } {&lt;br /&gt;
            puts stderr &amp;quot;Could not open $cmdfile for reading\n$err_msg&amp;quot;&lt;br /&gt;
            exit 1&lt;br /&gt;
         }&lt;br /&gt;
         &lt;br /&gt;
         # read in the file info - warning there is a limit on the size&lt;br /&gt;
         set send_text [read $cmdfile_fd 10000]&lt;br /&gt;
         &lt;br /&gt;
         # close open file&lt;br /&gt;
         close $cmdfile_fd      &lt;br /&gt;
      }&lt;br /&gt;
      &lt;br /&gt;
      # Connect to the host and login&lt;br /&gt;
      Connect &amp;quot;$method&amp;quot; &amp;quot;$hostname&amp;quot; &amp;quot;$username&amp;quot; &amp;quot;$password&amp;quot;   &lt;br /&gt;
      &lt;br /&gt;
      # If we have an enable password, lets try to send it&lt;br /&gt;
      if { [llength $enable_pw] &amp;gt; 0} {&lt;br /&gt;
         puts &amp;quot;***Using enable mode&amp;quot;&lt;br /&gt;
         send &amp;quot;enable\r&amp;quot;&lt;br /&gt;
         expect {&lt;br /&gt;
            -timeout 3&lt;br /&gt;
            # Below handles the password prompt&lt;br /&gt;
            -nocase -re &amp;quot;word:&amp;quot; {&lt;br /&gt;
               send &amp;quot;$enable_pw\r&amp;quot;&lt;br /&gt;
               exp_continue&lt;br /&gt;
      &lt;br /&gt;
            # Below handles the normal prompt to detect when logged in&lt;br /&gt;
            } -re &amp;quot;#\ *$&amp;quot; {&lt;br /&gt;
               puts &amp;quot;--SUCCESS on enable mode--&amp;quot;&lt;br /&gt;
&lt;br /&gt;
            # Below is for expect timeout waiting for a                                 &lt;br /&gt;
            } timeout {&lt;br /&gt;
               puts &amp;quot;ERROR: Enable password timeout&amp;quot;&lt;br /&gt;
               set rval 3&lt;br /&gt;
      &lt;br /&gt;
            # Below is for when the connect is closed before finishing   &lt;br /&gt;
            } eof {&lt;br /&gt;
               puts &amp;quot;ERROR: Connection to host failed: $expect_out(buffer)&amp;quot;&lt;br /&gt;
               set rval 4&lt;br /&gt;
            }         &lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
      &lt;br /&gt;
      # Loop through the send_text and send one line at a time         &lt;br /&gt;
      foreach line [split $send_text \n] {&lt;br /&gt;
         # Make sure to exclude empty lines&lt;br /&gt;
         if { [llength $line] &amp;gt; 0 } {           &lt;br /&gt;
            send &amp;quot;$line\r&amp;quot;&lt;br /&gt;
            &lt;br /&gt;
            # Start the expect/send process to login&lt;br /&gt;
            expect {            &lt;br /&gt;
               # Below handles the yes/no prompts  &lt;br /&gt;
               -nocase -re &amp;quot;\(yes/no\)&amp;quot; {&lt;br /&gt;
                  send &amp;quot;yes\r&amp;quot;&lt;br /&gt;
                  exp_continue&lt;br /&gt;
               &lt;br /&gt;
               # Below handles the y/n prompts  &lt;br /&gt;
               } -nocase -re &amp;quot;\(yes/no\)&amp;quot; {&lt;br /&gt;
                  send &amp;quot;yes\r&amp;quot;&lt;br /&gt;
                  exp_continue&lt;br /&gt;
&lt;br /&gt;
               # Below handles the y/n prompts  &lt;br /&gt;
               } -nocase -re &amp;quot;--more--&amp;quot; {&lt;br /&gt;
                  send &amp;quot; &amp;quot;&lt;br /&gt;
                  exp_continue&lt;br /&gt;
                                          &lt;br /&gt;
               # Below handles the normal prompt to detect when logged in&lt;br /&gt;
               } -nocase -re &amp;quot;$prompt&amp;quot; {&lt;br /&gt;
                  puts &amp;quot;\n--SUCCESS for normal login prompt--\n&amp;quot;&lt;br /&gt;
               }&lt;br /&gt;
            }&lt;br /&gt;
                &lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
      &lt;br /&gt;
      # Now that we are done, send an exit&lt;br /&gt;
      puts &amp;quot;*** Finished with script&amp;quot;&lt;br /&gt;
      send &amp;quot;exit\r&amp;quot;&lt;br /&gt;
      sleep 1&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
## END OF SCRIPT #############################################################&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
=== ASA show version using TELNET ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[network@network bin]$ ./vty_runcmd.exp -h 172.16.0.33 -u tim -p userpass -e enablepass&lt;br /&gt;
hostname = 172.16.0.33, user = tim, pw = userpass, method = telnet&lt;br /&gt;
Enter the send text (type 'end' on last line to finish):&lt;br /&gt;
show version&lt;br /&gt;
end&lt;br /&gt;
Connecting using telnet to 172.16.0.33 as user tim&lt;br /&gt;
spawn telnet 172.16.0.33&lt;br /&gt;
Using Process ID: 13811&lt;br /&gt;
Trying 172.16.0.33...&lt;br /&gt;
Connected to  FP-N1-7-FWSM-P1 (172.16.0.33).&lt;br /&gt;
Escape character is '^]'.&lt;br /&gt;
-===================================================================-&lt;br /&gt;
| Unauthorized access is prohibited!                                |&lt;br /&gt;
|                                                                   |&lt;br /&gt;
-===================================================================-&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
User Access Verification&lt;br /&gt;
&lt;br /&gt;
Warning: Authentication is enabled for system context. Use admin context credentials.&lt;br /&gt;
&lt;br /&gt;
Username: tim&lt;br /&gt;
Password: ********&lt;br /&gt;
Type help or '?' for a list of available commands.&lt;br /&gt;
FP-N1-7-FWSM-P1/PartnerFW&amp;gt; &lt;br /&gt;
SUCCESS: Logged in and ready to send commands&lt;br /&gt;
&lt;br /&gt;
***Using enable mode&lt;br /&gt;
enable&lt;br /&gt;
Password: ********&lt;br /&gt;
FP-N1-7-FWSM-P1/PartnerFW# --SUCCESS on enable mode--&lt;br /&gt;
show version&lt;br /&gt;
&lt;br /&gt;
FWSM Firewall Version 4.0(6) &amp;lt;context&amp;gt;&lt;br /&gt;
Device Manager Version 6.1(5)F&lt;br /&gt;
&lt;br /&gt;
Compiled on Mon 22-Jun-09 02:33 by fwsmbld&lt;br /&gt;
&lt;br /&gt;
FP-N1-7-FWSM-P1 up 55 days 11 hours&lt;br /&gt;
failover cluster up 116 days 12 hours&lt;br /&gt;
&lt;br /&gt;
Hardware:   WS-SVC-FWM-1&lt;br /&gt;
The Running Activation Key is not set, using default settings:&lt;br /&gt;
&lt;br /&gt;
Licensed features for this user context:&lt;br /&gt;
Failover                    : Active/Active&lt;br /&gt;
VPN-DES                     : Enabled   &lt;br /&gt;
VPN-3DES-AES                : Enabled   &lt;br /&gt;
GTP/GPRS                    : Disabled  &lt;br /&gt;
BGP Stub                    : Disabled  &lt;br /&gt;
Service Acceleration        : Disabled  &lt;br /&gt;
&lt;br /&gt;
Configuration last modified by tim at 23:42:12.528 UTC Mon Nov 1 2009&lt;br /&gt;
FP-N1-7-FWSM-P1/PartnerFW# &lt;br /&gt;
--SUCCESS for normal login prompt--&lt;br /&gt;
&lt;br /&gt;
*** Finished with script&lt;br /&gt;
[network@network bin]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===ASA show version using SSH - automatically accepts RSA key ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[network@network ~]$ bin/vty_runcmd.exp -m ssh -h 172.16.0.33 -u tim -p userpass -e enablepass&lt;br /&gt;
hostname = 172.16.0.33, user = tim, pw = userpass, method = ssh&lt;br /&gt;
Enter the send text (type 'end' on last line to finish):&lt;br /&gt;
show ver&lt;br /&gt;
end&lt;br /&gt;
Connecting using ssh to 172.16.0.33 as user tim&lt;br /&gt;
spawn ssh tim@172.16.0.33&lt;br /&gt;
Using Process ID: 14855&lt;br /&gt;
The authenticity of host '172.16.0.33 (172.16.0.33)' can't be established.&lt;br /&gt;
RSA key fingerprint is 1d:81:48:7e:ec:5a:ba:e1:f5:e5:a3:92:41:a8:6a:61.&lt;br /&gt;
Are you sure you want to continue connecting (yes/no)? yes&lt;br /&gt;
Warning: Permanently added '172.16.0.33' (RSA) to the list of known hosts.&lt;br /&gt;
tim@172.16.0.33's password: &lt;br /&gt;
-===================================================================-&lt;br /&gt;
| Unauthorized access is prohibited!                                |&lt;br /&gt;
|                                                                   |&lt;br /&gt;
-===================================================================-&lt;br /&gt;
Type help or '?' for a list of available commands.&lt;br /&gt;
FP-N1-7-FWSM-P1/PartnerFW&amp;gt; &lt;br /&gt;
SUCCESS: Logged in and ready to send commands&lt;br /&gt;
&lt;br /&gt;
***Using enable mode&lt;br /&gt;
enable&lt;br /&gt;
Password: ********&lt;br /&gt;
FP-N1-7-FWSM-P1/PartnerFW# --SUCCESS on enable mode--&lt;br /&gt;
show ver&lt;br /&gt;
&lt;br /&gt;
FWSM Firewall Version 4.0(6) &amp;lt;context&amp;gt;&lt;br /&gt;
Device Manager Version 6.1(5)F&lt;br /&gt;
&lt;br /&gt;
Compiled on Mon 22-Jun-09 02:33 by fwsmbld&lt;br /&gt;
&lt;br /&gt;
FP-N1-7-FWSM-P1 up 55 days 11 hours&lt;br /&gt;
failover cluster up 116 days 12 hours&lt;br /&gt;
&lt;br /&gt;
Hardware:   WS-SVC-FWM-1&lt;br /&gt;
The Running Activation Key is not set, using default settings:&lt;br /&gt;
&lt;br /&gt;
Licensed features for this user context:&lt;br /&gt;
Failover                    : Active/Active&lt;br /&gt;
VPN-DES                     : Enabled   &lt;br /&gt;
VPN-3DES-AES                : Enabled   &lt;br /&gt;
GTP/GPRS                    : Disabled  &lt;br /&gt;
BGP Stub                    : Disabled  &lt;br /&gt;
Service Acceleration        : Disabled  &lt;br /&gt;
&lt;br /&gt;
Configuration last modified by enable_15 at 06:05:31.674 UTC Mon Nov 1 2009&lt;br /&gt;
FP-N1-7-FWSM-P1/PartnerFW# &lt;br /&gt;
--SUCCESS for normal login prompt--&lt;br /&gt;
&lt;br /&gt;
*** Finished with script&lt;br /&gt;
[network@network ~]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Remote VTY Command Script]]&lt;/div&gt;</summary>
		<author><name>Tievens</name></author>	</entry>

	</feed>