blob: d27448d72feed25430636a3a30f89d65e19cb324 [file] [log] [blame]
#!/usr/local/plan9/bin/rc
if(! ~ $#* 2){
echo usage: netfilestat system path >[1=2]
exit usage
}
f=dostat
. netfilelib.rc $1
fn dostat {
echo cd $2 | runsftp $1
if(9 test -e $t.sftp -a ! -s $t.sftp){
echo directory
exit 0
}
if(9 grep -s 'Can''t change directory|is not a directory' $t.sftp){
echo file
exit 0
}
if(9 grep -s 'Couldn''t stat remote file|such file' $t.sftp){
echo nonexistent
exit 0
}
{
echo unknown error:
sed 's/^/ /' $t.sftp
} >[1=2]
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