blob: f01c5de6aa8ce8d8eaf279e477504b408af2fb0d (
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
45
46
|
#!/usr/local/plan9/bin/rc
if(! ~ $#* 2){
echo usage: netfilestat system path >[1=2]
exit usage
}
f=dostat
. netfilelib.rc $1
fn dostat {
{
9 echo -cd $2
} | mysftp $1 >$t
if(9 test -e $t -a ! -s $t){
echo directory
exit 0
}
if(9 grep -s 'Can''t change directory|is not a directory' $t){
echo file
exit 0
}
if(9 grep -s 'Couldn''t stat remote file|such file' $t){
echo nonexistent
exit 0
}
cat $t >[1=2]
echo unknown error
exit 0
}
fn dostat9p {
if(! 9p ls -ld $1/$2 >$t >[2]/dev/null){
echo nonexistent
exit 0
}
if(9 grep -s '^d' $t){
echo directory
exit 0
}
echo file
exit 0
}
$f $1 $2
|