#!/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