branch14.org

 1 #!/usr/bin/expect
       2 
       3 set host 192.168.0.1
       4 set port 9000
       5 set CTRLC \003
       6 
       7 set server 192.168.0.2
       8 set image ramdisk.gz
       9 set kernel vmlinuz
      10 
      11 while {1} {
      12     set pid [spawn telnet $host $port]
      13     expect {
      14         "telnet: Unable to connect to remote host: No route to host" {
      15             send_user -- "\#\#\# START YOUR SLUG NOW\n"
      16         }
      17         "telnet: Unable to connect to remote host: Connection refused" {
      18             send_user "damn we missed it. how could that happen?\n"
      19             exit
      20         }
      21         "enter ^C to abort" {
      22             send $CTRLC
      23             sleep 1
      24             send "ip_address -h $server\r"
      25             sleep 1
      26             send_user "\n"
      27             send_user "=== erase SysConf ===\n"
      28             send_user "> fis erase -f 0x50040000 -l 0x20000\n"
      29             send_user "=== test ============\n"
      30             send_user "> load -r -v -b 0x01000000 -m http /$image\n"
      31             send_user "> load -r -v -b 0x01d00000 -m http /$kernel\n"
      32             send_user "> exec 0x01d00000\n"
      33             send_user "=== flash ===========\n"
      34             send_user "> load -r -v -b 0x01000000 -m http /NSLU2_V23R25.bin\n"
      35             send_user "> load -r -v -b 0x01000000 -m http /di-nslu2.bin\n"
      36             send_user "> load -r -v -b 0x01000000 -m http /sda1-2.6.18-4.bin\n"
      37             send_user "> fis write -f 0x50060000 -b 0x01060000 -l 0x7a0000\n"
      38             interact
      39             exit
      40         } 
      41     }
      42 }
      

expect into redboot

  • snippet type: utility
  • keywords: nslu2, slug, redboot, nas
  • language: expect

this expect script can be used to sneak into the redboot telnet
session of you linksys nslu2 (aka slug). if you play a lot with these
little devices this script comes handy.

more on nslu2