Blob


1 #!/usr/local/plan9/bin/rc
3 if(! ~ $#* 2){
4 echo usage: netisdir system path >[1=2]
5 exit usage
6 }
8 t=/tmp/netisdir.$pid.$USER
9 fn sigexit { rm -f $t }
11 {
12 echo !echo XXX connected
13 echo cd $2
14 echo !echo XXX directory exists
15 } | sftp -b - $1 >$t >[2=1]
16 if(9 grep -s XXX.directory.exists $t){
17 echo directory
18 exit 0
19 }
20 if(9 grep -s 'is not a directory' $t){
21 echo file
22 exit 0
23 }
24 cat $t | sed 's/sftp> //g; /^$/d; /XXX/d; /^cd /d' >[1=2]
25 if(! 9 grep -s XXX.connected $t){
26 echo connect failed
27 exit 0
28 }
29 echo nonexistent
30 exit 0