From 0b18afa8cc438c6a18951db78f62a548b75a1eb2 Mon Sep 17 00:00:00 2001 From: Bart Van Der Meerssche Date: Mon, 2 May 2011 16:47:06 +0200 Subject: [PATCH] [tools] add redboot.pl script to repo --- mote/v2/tools/redboot.pl | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 mote/v2/tools/redboot.pl diff --git a/mote/v2/tools/redboot.pl b/mote/v2/tools/redboot.pl new file mode 100755 index 0000000..c30800d --- /dev/null +++ b/mote/v2/tools/redboot.pl @@ -0,0 +1,39 @@ +#!/usr/bin/perl -w +# telnet_redboot.pl - ./upslug --reset;arping -f 192.168.0.1;telnet 192.168.0.1 9000 + +use Net::Telnet (); + +my $host = $ARGV[0] or die "Syntax: $0 \n"; + + system("while true; do fping -t200 $host && break; done"); + + my $t = new Net::Telnet (Port => 9000, Timeout => 30); + if(!defined($t)){ + print "new Net::Telnet failed\n"; + exit(1); + } # if + my $ok; + $ok = $t->errmode("return"); + $ok = $t->open($host); + if(!defined($ok)){ + print "open('$host') failed\n"; + $t->close(); + exit(1); + } # if + + # == Executing boot script in 1.930 seconds - enter ^C to abort + + my $line; + while($line = $t->getline()){ + $line =~ s/[\r\n]//; + print "-> $line\n"; + if($line =~ m/enter \^C to abort/){ + $t->put(chr(3)); # send ^C + print "<- \^C\n"; + $t->close(); + sleep(1); + system("telnet $host 9000"); + exit(0); + } # if + } # while + $t->close();