<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Cisco/Expect Help in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/cisco-expect-help/m-p/3276762#M72046</link>
    <description>Hello All,&lt;BR /&gt;&lt;BR /&gt;I am having a bugger of a time getting this script to function.  Its purpose is to log into a remote router, execute a `copy tftp run`, and exit.&lt;BR /&gt;&lt;BR /&gt;The script does log into the router, but never seems to execute the `copy tftp run` portion.&lt;BR /&gt;&lt;BR /&gt;Can anyone please help?&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/expect -f&lt;BR /&gt;#&lt;BR /&gt;#&lt;BR /&gt;#&lt;BR /&gt;#&lt;BR /&gt;# usage:  upload-config hostname username password configfilename&lt;BR /&gt;#&lt;BR /&gt;#&lt;BR /&gt;#&lt;BR /&gt;if { [llength $argv] &amp;lt; 5} {&lt;BR /&gt;puts "usage: upload hostname username password tftpip confgfilename"&lt;BR /&gt;exit 1&lt;BR /&gt;}&lt;BR /&gt;set router [lindex $argv 0]&lt;BR /&gt;set username [lindex $argv 1]&lt;BR /&gt;set password [lindex $argv 2]&lt;BR /&gt;set tftpip [lindex $argv 3]&lt;BR /&gt;set confgfilename [lindex $argv 4]&lt;BR /&gt;set timeout 20&lt;BR /&gt;&lt;BR /&gt;log_user 0&lt;BR /&gt;spawn telnet $router&lt;BR /&gt;&lt;BR /&gt;expect {&lt;BR /&gt;"Username:" {send $username\r}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;expect {&lt;BR /&gt;"Password:" {send $password\r}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;expect {&lt;BR /&gt;"#" {send "copy tftp run\n"}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;expect {&lt;BR /&gt;"Address" {send $tftpip\r}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;expect {&lt;BR /&gt;"Source" {send $confgfilename\r}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;expect {&lt;BR /&gt;"Destination" {send "run\r"}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;sleep 15&lt;BR /&gt;&lt;BR /&gt;exit 0&lt;BR /&gt;</description>
    <pubDate>Fri, 14 May 2004 11:29:16 GMT</pubDate>
    <dc:creator>Michael Lyon</dc:creator>
    <dc:date>2004-05-14T11:29:16Z</dc:date>
    <item>
      <title>Cisco/Expect Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/cisco-expect-help/m-p/3276762#M72046</link>
      <description>Hello All,&lt;BR /&gt;&lt;BR /&gt;I am having a bugger of a time getting this script to function.  Its purpose is to log into a remote router, execute a `copy tftp run`, and exit.&lt;BR /&gt;&lt;BR /&gt;The script does log into the router, but never seems to execute the `copy tftp run` portion.&lt;BR /&gt;&lt;BR /&gt;Can anyone please help?&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/expect -f&lt;BR /&gt;#&lt;BR /&gt;#&lt;BR /&gt;#&lt;BR /&gt;#&lt;BR /&gt;# usage:  upload-config hostname username password configfilename&lt;BR /&gt;#&lt;BR /&gt;#&lt;BR /&gt;#&lt;BR /&gt;if { [llength $argv] &amp;lt; 5} {&lt;BR /&gt;puts "usage: upload hostname username password tftpip confgfilename"&lt;BR /&gt;exit 1&lt;BR /&gt;}&lt;BR /&gt;set router [lindex $argv 0]&lt;BR /&gt;set username [lindex $argv 1]&lt;BR /&gt;set password [lindex $argv 2]&lt;BR /&gt;set tftpip [lindex $argv 3]&lt;BR /&gt;set confgfilename [lindex $argv 4]&lt;BR /&gt;set timeout 20&lt;BR /&gt;&lt;BR /&gt;log_user 0&lt;BR /&gt;spawn telnet $router&lt;BR /&gt;&lt;BR /&gt;expect {&lt;BR /&gt;"Username:" {send $username\r}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;expect {&lt;BR /&gt;"Password:" {send $password\r}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;expect {&lt;BR /&gt;"#" {send "copy tftp run\n"}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;expect {&lt;BR /&gt;"Address" {send $tftpip\r}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;expect {&lt;BR /&gt;"Source" {send $confgfilename\r}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;expect {&lt;BR /&gt;"Destination" {send "run\r"}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;sleep 15&lt;BR /&gt;&lt;BR /&gt;exit 0&lt;BR /&gt;</description>
      <pubDate>Fri, 14 May 2004 11:29:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/cisco-expect-help/m-p/3276762#M72046</guid>
      <dc:creator>Michael Lyon</dc:creator>
      <dc:date>2004-05-14T11:29:16Z</dc:date>
    </item>
    <item>
      <title>Re: Cisco/Expect Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/cisco-expect-help/m-p/3276763#M72047</link>
      <description>Script looks Ok; I did notice that the expect {&lt;BR /&gt;" " {send  xxx } for the line in question ends with \n whereas all the others end with \r&lt;BR /&gt;&lt;BR /&gt;(newline vs return)&lt;BR /&gt;&lt;BR /&gt;This may have some effect.&lt;BR /&gt;{send "copy tftp run\n"}&lt;BR /&gt;vs&lt;BR /&gt;{Destination" {send "run\r"}&lt;BR /&gt;&lt;BR /&gt;I would try replacing the \n with \r just for kicks :o)&lt;BR /&gt;&lt;BR /&gt;Vern</description>
      <pubDate>Fri, 14 May 2004 14:56:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/cisco-expect-help/m-p/3276763#M72047</guid>
      <dc:creator>Vernon Brown_4</dc:creator>
      <dc:date>2004-05-14T14:56:08Z</dc:date>
    </item>
    <item>
      <title>Re: Cisco/Expect Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/cisco-expect-help/m-p/3276764#M72048</link>
      <description>No cisco gives a '#' at login from external that I'm aware of.&lt;BR /&gt;&lt;BR /&gt;It gives a 'Name&amp;gt;' prompt first, then you have to jump into enabled mode before using the 'copy' command.&lt;BR /&gt;&lt;BR /&gt;It'd help if you'd show us the output, the failure, when you do this command, but you'll need to change 'log_user 0' to 'log_user 1' (i.e. show you what it's doing).</description>
      <pubDate>Fri, 14 May 2004 18:47:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/cisco-expect-help/m-p/3276764#M72048</guid>
      <dc:creator>Stuart Browne</dc:creator>
      <dc:date>2004-05-14T18:47:59Z</dc:date>
    </item>
  </channel>
</rss>

