blob: ad2d626598ef798adf453f067cc50c93e4e31779 (
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
|
#!/usr/local/plan9/bin/rc
f=getfile
if(~ $1 -d){
f=getdir
shift
}
if(! ~ $#* 2){
echo 'usage: netfileget [-d] system path' >[1=2]
exit usage
}
. netfilelib.rc $1
fn getfile {
rm -f $t
if(! 9 echo -get $2 $t | mysftp $1 >$t.e >[2=1])
exit 1
egrep -v '^Fetching' $t.e >$t.e2
if(test -s $t.e2){
cat $t.e >[1=2]
exit 1
}
cat $t
}
fn getfile9p {
if(! 9p read $1/$2)
exit 1
}
fn getdir {
if(! {echo cd $2; echo ls -l} | mysftp $1 | sed '1,2d; s/sftp> //g; /^$/d' >$t)
exit 1
cat $t | awk '$NF == "." || $NF == ".." { next } {s = $NF; if($0 ~ /^d/) s = s "/"; print s}'
}
fn getdir9p {
9p ls -l $1/$2 | awk '{s=$NF; if($0 ~ /^d/) s=s"/"; print s}'
}
$f $1 $2
exit 0
|