Revision: | 1.12 |
Committed: | Sat Apr 14 15:12:30 2007 UTC (17 years, 2 months ago) by root |
Branch: | MAIN |
CVS Tags: | rel-4_91, rel-4_22, rel-4_21, rel-4_0, rel-4_3, rel-4_13, rel-4_11, rel-5_0, rel-4_748, rel-4_8, rel-4_9, rel-4_741, rel-4_743, rel-4_742, rel-4_744, rel-4_747, rel-4_01, rel-4_03, rel-4_02, rel-3_6, rel-3_62, rel-3_63, rel-3_61, rel-4_74, rel-4_71, rel-4_72, rel-4_73, rel-4_802, rel-4_803, rel-4_801, rel-4_804, rel-4_479, rel-4_50, rel-4_51, rel-4_4, rel-4_45, rel-4_745, rel-4_901, rel-4_49, rel-4_48, rel-4_1, rel-4_2, rel-4_746, rel-4_47, rel-4_46, rel-4_7, rel-4_911, rel-4_912, rel-4_31, rel-4_32, rel-4_33, rel-4_34, rel-4_35, rel-4_36, rel-4_37 |
Changes since 1.11: | +23 -27 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.4 | sub timer : Coro { |
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.1 | } |
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 | $quit->send; | ||
49 | } else { | ||
50 | print "unknown command '$cmd', either 'finger' or 'quit'\n"; | ||
51 | } | ||
52 | } | ||
53 | root | 1.1 |