-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfinger.js
47 lines (39 loc) · 972 Bytes
/
finger.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// $Id: finger.js,v 1.8 2019/01/12 01:47:34 rswindell Exp $
// A simple finger/systat (who) client suitable for running via the BBS or JSexec
"use strict";
var lib = load({}, "finger_lib.js");
var dest;
var use_udp = false;
var protocol = "finger";
var i;
for(i = 0; i < argc; i++) {
if(argv[i] == '-udp')
use_udp = true;
else if(argv[i] == '-s')
protocol = "systat";
else if(argv[i].indexOf('@')!=-1)
dest = argv[i];
else {
alert("Unsupported option: " + argv[i]);
exit();
}
}
function finger(dest, protocol, use_udp)
{
if(!dest && (dest = prompt("User (user@hostname)"))==null)
return;
writeln();
var hp;
if((hp = dest.indexOf('@')) == -1) {
dest += "@" + system.host_name;
hp = dest.indexOf('@')
}
var host = dest.slice(hp + 1);
var result = lib.request(host, dest.slice(0, hp), protocol, use_udp);
if(typeof result != 'object')
alert(result);
else
for(var i in result)
writeln(result[i]);
}
finger(dest, protocol, use_udp);