#!/bin/rc
# Given remote mount path (or cwd), tell the best cpu to run commands on.
#
# To publish: cp $% /n/sources/contrib/yk/lab/unix9/
rfork e
fn winprefix { </mnt/acme/$winid/tag sed 's! .*!!; s!/[^/]+$!!; 1q' }
if(~ $#* 1)
dir = $1
if not {
if(! ~ $#winid 0 && ! ~ $winid '')
dir = `{winprefix}
if(~ $#dir 0 || ~ $dir '')
dir = `{pwd}
}
if(! ~ $dir /n/*)
exit 'not remote'
mnt = `{echo $dir | sed 's!^(/n/[^/]*).*!\1!'}
if(remote = `{cat $mnt/etc/hostname >[2]/dev/null}) {
if(ruser = `{
ls -ld $mnt/proc/self |
sed 's/^[^ ]+ [^ ]+ [^ ]+ ([^ ]+) .*/\1/'
})
echo $ruser@$remote
if not
echo $remote
exit
}
remote = `{basename $mnt}
if(! ~ $remote local remote other sources) {
echo $remote
exit
}
exit 'unknown'
|