summaryrefslogtreecommitdiffstats
path: root/scripts/usb/procusb
blob: f88f35fcc7515ee8e0dd5a979d489e792b3b28a1 (plain)
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
#!/usr/bin/perl

# Reads /proc/bus/usb/devices and selectively lists and/or
# interprets it.

$DEVFILENAME = "/proc/bus/usb/devices";
$PROGNAME = $0;

print "\n";

$TAGS = $ARGV[0];		# save user TAGS
if (length ($TAGS) == 0)
{
	print "usage: $PROGNAME tags\n";
	print "  where 'tags' can be any number of 'TBDPCIE' or 'A(LL)'\n";
	exit 1;
}

$ALL = ($TAGS =~ /all/i) || ($TAGS =~ /a/i);

# TBD: Check that $TAGS is valid.
if (! $ALL)
{
}

if (! open (DEVNUM, "<$DEVFILENAME"))
{
	print "$PROGNAME: cannot open '$DEVFILENAME'\n";
	exit 1;
}

while ($line = <DEVNUM>)	# read a text line from DEVNUM
{
	if (($ALL) || ($line =~ /^[$TAGS]:/i))	# any of TAGS at beg. of line?
	{
		print "$line";	# still has newline char on it
				# TBD: add more/paging functionality.
	}
} # end while DEVNUM

close (DEVNUM);
print "\n";

# END.