]> git.lizzy.rs Git - plan9front.git/blobdiff - rc/bin/rcpu
torrent(1): update url in examples section
[plan9front.git] / rc / bin / rcpu
index 086392e6a3fe6c566bf3a473b4f3ad11a1cd1208..54f670c674ef674c365a35502e09e2b175d0f2e9 100755 (executable)
@@ -3,7 +3,7 @@ rfork e
 
 argv0=$0
 fn usage {
-       echo 'usage:' $argv0 '[-p] [-h host] [-u user] [-k keypattern] [-P patternfile] [-c cmd arg ...]' >[1=2]
+       echo 'usage:' $argv0 '[-u user] [-k keypattern] [-P patternfile] [-p] [-t timeout] [-h host] [-c cmd arg ...]' >[1=2]
        exit 'usage'
 }
 
@@ -23,11 +23,11 @@ fn server {
        if(test -d /mnt/term/mnt/cpunote) {
                rfork e
                mainproc=$apid
-               exec cat </mnt/term/mnt/cpunote/data >/proc/$mainproc/notepg &
+               {cat; echo -n hangup} </mnt/term/mnt/cpunote/data >/proc/$mainproc/notepg &
                noteproc=$apid
                wait $mainproc
                echo -n $status >/mnt/term/env/rstatus >[2]/dev/null
-               echo -n kill >/proc/$noteproc/note
+               echo -n hangup >/proc/$noteproc/notepg
        }
 }
 
@@ -52,6 +52,7 @@ fn client {
 
 cmd=()
 host='$cpu'
+if(~ $#cpu 1) host=$cpu
 exportfs=/bin/exportfs
 connect=/bin/rconnect
 
@@ -62,7 +63,7 @@ while(~ $1 -*){
                ~ $#* 1 && usage
                switch($1){
                case -P; exportfs=($exportfs $1 $2)
-               case -[uk]; connect=($connect $1 $2)
+               case -[ukt]; connect=($connect $1 $2)
                case -h; host=$2
                case -c; cmd=$*(2-); *=()
                case *; usage
@@ -75,9 +76,15 @@ while(~ $1 -*){
 
 fn pvar {
        while(! ~ $#* 0){
-               ~ $#$1 0 || path=/dev/null builtin whatis $1
+               ~ $#$1 0 && echo $1'=()' ||
+                       path=/dev/null builtin whatis $1
                shift
        }
 }
 
-exec $connect $host <{dir=`{pwd} pvar dir cmd; builtin whatis server; echo server} client <[10=0] >[11=1] >[12=2]
+>/env/rscript {
+       dir=`{pwd} pvar dir cmd
+       builtin whatis server
+       echo server
+}
+exec $connect $host /env/rscript client <[10=0] >[11=1] >[12=2]