plan9port/bin/netfileput

28 lines
349 B
Text
Raw Normal View History

2005-03-18 19:00:09 +00:00
#!/usr/local/plan9/bin/rc
if(! ~ $#* 2){
echo 'usage: netput system path' >[1=2]
exit usage
}
2005-03-18 19:27:03 +00:00
f=putfile
ns=`{namespace}
if(u test -S $ns/$1)
f=$f^9p
2005-03-18 19:00:09 +00:00
t=/tmp/netget.$pid.$USER
fn sigexit { rm -f $t }
2005-03-18 19:27:03 +00:00
fn putfile{
cat >$t
if(! echo put $t $2 | sftp -b - $1 >/dev/null)
exit 1
}
fn putfile9p{
if(! 9p write $1/$2)
exit 1
}
$f $1 $2
2005-03-18 19:00:09 +00:00
exit 0