OpenCores
URL https://opencores.org/ocsvn/w11/w11/trunk

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.6/] [tools/] [bin/] [telnet_wrapper] - Blame information for rev 24

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 wfjm
#!/usr/bin/perl -w
2 22 wfjm
# $Id: telnet_wrapper 547 2013-12-29 13:10:07Z mueller $
3 2 wfjm
#
4 21 wfjm
# Copyright 2009-2013 by Walter F.J. Mueller 
5 2 wfjm
#
6
# This program is free software; you may redistribute and/or modify it under
7
# the terms of the GNU General Public License as published by the Free
8
# Software Foundation, either version 2, or at your option any later version.
9
#
10
# This program is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
12
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13
# for complete details.
14
#
15
#  Revision History:
16 22 wfjm
# Date         Rev  Vers    Comment
17 2 wfjm
# 2009-11-07   246   1.0    Initial version
18
#
19
 
20
use 5.005;                                  # require Perl 5.005 or higher
21
use strict;                                 # require strict checking
22
 
23
if (scalar(@ARGV) != 2) {
24
  print STDERR "usage: telnet_wrapper host port\n";
25
  exit 1;
26
}
27
 
28
my $host = $ARGV[0];
29
my $port = $ARGV[1];
30
 
31
print "$host $port\n";
32
 
33
my $telnet = `which telnet`;
34
chomp $telnet;
35
 
36
while(1) {
37
  my $rc = system $telnet, $host, $port;
38
  if ($rc != 0) {
39
    print STDERR "telnet failed with rc=$rc\n";
40
  }
41 21 wfjm
  print "enter q or <^D> to quit, otherwise hit  to reconnect: ";
42 2 wfjm
  my $buf;
43
  my $nc = read STDIN, $buf, 1;
44
  if (not defined $nc) {
45
    print "\n";
46
    exit 1;
47
  }
48
  if ($nc == 0) {
49
    print "\n";
50
    exit 0;
51
  }
52
  if ($buf eq "q") {
53
    exit 0;
54
  }
55
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.