Blob


1 #!/usr/local/plan9/bin/rc
3 if(! ~ $#* 2){
4 echo usage: netfilestat system path >[1=2]
5 exit usage
6 }
8 f=dostat
10 . netfilelib.rc $1
12 fn dostat {
13 echo cd $2 | runsftp $1
14 if(9 test -e $t.sftp -a ! -s $t.sftp){
15 echo directory
16 exit 0
17 }
18 if(9 grep -s 'Can''t change directory|is not a directory' $t.sftp){
19 echo file
20 exit 0
21 }
22 if(9 grep -s 'Couldn''t stat remote file|such file' $t.sftp){
23 echo nonexistent
24 exit 0
25 }
26 {
27 echo unknown error:
28 sed 's/^/ /' $t.sftp
29 } >[1=2]
30 exit 0
31 }
33 fn dostat9p {
34 if(! 9p ls -ld $1/$2 >$t >[2]/dev/null){
35 echo nonexistent
36 exit 0
37 }
38 if(9 grep -s '^d' $t){
39 echo directory
40 exit 0
41 }
42 echo file
43 exit 0
44 }
46 $f $1 $2