plan9port/src/cmd/netfiles/netfileget

47 lines
552 B
Text
Raw Normal View History

2005-03-18 19:30:22 +00:00
#!/usr/local/plan9/bin/rc
f=getfile
if(~ $1 -d){
f=getdir
shift
}
if(! ~ $#* 2){
2005-03-20 23:39:48 +00:00
echo 'usage: netfileget [-d] system path' >[1=2]
2005-03-18 19:30:22 +00:00
exit usage
}
2005-03-21 07:37:34 +00:00
. netfilelib.rc $1
2005-03-18 19:30:22 +00:00
fn getfile9p {
if(! 9p read $1/$2)
exit 1
}
fn getdir9p {
9p ls -l $1/$2 | awk '{s=$NF; if($0 ~ /^d/) s=s"/"; print s}'
}
2005-03-24 05:17:01 +00:00
fn getfile {
rm -f $t
echo get $2 $t | runsftp -e $1
cat $t
}
fn getdir {
{echo cd $2; echo ls -l} | runsftp $1
awk '
$NF == "." || $NF == ".." { next }
{
s = $NF
if($0 ~ /^d/)
s = s "/"
print s
}
' $t.sftp
}
2005-03-18 19:30:22 +00:00
$f $1 $2
exit 0