new files
This commit is contained in:
parent
72fd2f8819
commit
7c709434ec
9 changed files with 1504 additions and 0 deletions
45
src/cmd/netfiles/netfileget
Executable file
45
src/cmd/netfiles/netfileget
Executable file
|
|
@ -0,0 +1,45 @@
|
|||
#!/usr/local/plan9/bin/rc
|
||||
|
||||
f=getfile
|
||||
if(~ $1 -d){
|
||||
f=getdir
|
||||
shift
|
||||
}
|
||||
|
||||
if(! ~ $#* 2){
|
||||
echo 'usage: netget [-d] system path' >[1=2]
|
||||
exit usage
|
||||
}
|
||||
|
||||
ns=`{namespace}
|
||||
if(u test -S $ns/$1)
|
||||
f=$f^9p
|
||||
|
||||
t=/tmp/netget.$pid.$USER
|
||||
fn sigexit { rm -f $t }
|
||||
|
||||
fn getfile {
|
||||
rm -f $t
|
||||
if(! echo get $2 $t | sftp -b - $1 >/dev/null)
|
||||
exit 1
|
||||
cat $t
|
||||
}
|
||||
|
||||
fn getfile9p {
|
||||
if(! 9p read $1/$2)
|
||||
exit 1
|
||||
}
|
||||
|
||||
fn getdir {
|
||||
if(! {echo cd $2; echo ls -l} | sftp -b - $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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue