URL
https://opencores.org/ocsvn/w11/w11/trunk
Subversion Repositories w11
[/] [w11/] [tags/] [w11a_V0.6/] [tools/] [bin/] [telnet_wrapper] - Rev 25
Go to most recent revision | Compare with Previous | Blame | View Log
#!/usr/bin/perl -w
# $Id: telnet_wrapper 547 2013-12-29 13:10:07Z mueller $
#
# Copyright 2009-2013 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
#
# This program is free software; you may redistribute and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 2, or at your option any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for complete details.
#
# Revision History:
# Date Rev Vers Comment
# 2009-11-07 246 1.0 Initial version
#
use 5.005; # require Perl 5.005 or higher
use strict; # require strict checking
if (scalar(@ARGV) != 2) {
print STDERR "usage: telnet_wrapper host port\n";
exit 1;
}
my $host = $ARGV[0];
my $port = $ARGV[1];
print "$host $port\n";
my $telnet = `which telnet`;
chomp $telnet;
while(1) {
my $rc = system $telnet, $host, $port;
if ($rc != 0) {
print STDERR "telnet failed with rc=$rc\n";
}
print "enter q or <^D> to quit, otherwise hit <ENTER> to reconnect: ";
my $buf;
my $nc = read STDIN, $buf, 1;
if (not defined $nc) {
print "\n";
exit 1;
}
if ($nc == 0) {
print "\n";
exit 0;
}
if ($buf eq "q") {
exit 0;
}
}
Go to most recent revision | Compare with Previous | Blame | View Log