| Revision: | 1.13 |
| Committed: | Mon Nov 24 04:56:38 2008 UTC (17 years, 11 months ago) by root |
| Branch: | MAIN |
| CVS Tags: | rel-5_151, rel-5_1, rel-6_0, rel-6_5, rel-6_10, rel-6_13, rel-6_09, rel-6_08, rel-6_07, rel-6_06, rel-6_05, rel-6_04, rel-6_03, rel-6_02, rel-6_01, rel-5_161, rel-5_371, rel-5_372, rel-6_512, rel-6_513, rel-6_511, rel-6_514, rel-5_22, rel-5_23, rel-5_24, rel-5_25, rel-6_32, rel-6_33, rel-6_31, rel-6_36, rel-6_37, rel-5_162, rel-5_2, rel-6_38, rel-6_39, rel-5_37, rel-5_36, rel-6_23, rel-6_29, rel-6_28, rel-6_46, rel-6_45, rel-6_51, rel-6_52, rel-6_53, rel-6_54, rel-6_55, rel-6_56, rel-6_57, rel-5_11, rel-5_12, rel-5_15, rel-5_14, rel-5_17, rel-5_16, rel-6_43, rel-6_42, rel-6_41, rel-6_47, rel-5_132, rel-5_131, rel-6_44, rel-6_49, rel-6_48, HEAD |
| Changes since 1.12: | +3 -3 lines |
| Log Message: | *** empty log message *** |
| # | User | Rev | Content |
|---|---|---|---|
| 1 | root | 1.1 | #!/usr/bin/perl |
| 2 | |||
| 3 | root | 1.10 | # this crap is an asynchronous finger client. it's rather idiotic ;) |
| 4 | root | 1.5 | |
| 5 | root | 1.1 | use Coro; |
| 6 | root | 1.12 | use Coro::Socket; |
| 7 | root | 1.1 | use Coro::Event; |
| 8 | root | 1.12 | use AnyEvent; |
| 9 | |||
| 10 | my $quit = AnyEvent->condvar; | ||
| 11 | root | 1.2 | |
| 12 | root | 1.6 | # this gets started everytime a user enters a finger command |
| 13 | root | 1.4 | sub finger { |
| 14 | root | 1.6 | my $user = shift; |
| 15 | root | 1.4 | my $host = shift; |
| 16 | root | 1.7 | |
| 17 | root | 1.8 | my $fh = new Coro::Socket PeerHost => $host, PeerPort => "finger" |
| 18 | root | 1.9 | or die "$user\@$host: $!"; |
| 19 | root | 1.7 | |
| 20 | print $fh "$user\n"; | ||
| 21 | |||
| 22 | print "$user\@$host: $_" while <$fh>; | ||
| 23 | print "$user\@$host: done\n"; | ||
| 24 | root | 1.4 | } |
| 25 | |||
| 26 | root | 1.6 | # display the time or garble the display, YMMV. |
| 27 | root | 1.13 | async { |
| 28 | root | 1.12 | my $w = Coro::Event->timer (interval => 0.001, hard => 1); |
| 29 | root | 1.4 | use Time::HiRes qw(time); |
| 30 | root | 1.2 | while () { |
| 31 | $w->next; | ||
| 32 | root | 1.12 | print "\e7\e[C\e[C\e[C\e[C\e[C\e[C\e[C\e[C <time ", time, "> \e8"; |
| 33 | root | 1.2 | }; |
| 34 | root | 1.13 | }; |
| 35 | root | 1.2 | |
| 36 | root | 1.12 | my $stdin = new_from_fh Coro::Handle \*STDIN; |
| 37 | |||
| 38 | $SIG{PIPE} = 'IGNORE'; | ||
| 39 | |||
| 40 | $| = 1; | ||
| 41 | while() { | ||
| 42 | print "cmd (finger|quit)> "; my $cmd = <$stdin>; chomp $cmd; | ||
| 43 | if ($cmd eq "finger") { | ||
| 44 | print "user> "; my $user = <$stdin>; chomp $user; | ||
| 45 | print "host> "; my $host = <$stdin>; chomp $host; | ||
| 46 | async { finger $user, $host }; | ||
| 47 | } elsif ($cmd eq "quit") { | ||
| 48 | root | 1.13 | last; |
| 49 | root | 1.12 | } else { |
| 50 | print "unknown command '$cmd', either 'finger' or 'quit'\n"; | ||
| 51 | } | ||
| 52 | } | ||
| 53 | root | 1.1 |