3 # Attach to a Mininet host and run a command
6 echo "usage: $0 host cmd [args...]"
12 pid=`ps ax | grep "mininet:$host$" | grep bash | grep -v mnexec | awk '{print $1};'`
14 if echo $pid | grep -q ' '; then
15 echo "Error: found multiple mininet:$host processes"
19 if [ "$pid" == "" ]; then
20 echo "Could not find Mininet host $host"
31 cgroup=/sys/fs/cgroup/cpu/$host
32 if [ -d "$cgroup" ]; then
36 # Check whether host should be running in a chroot dir
37 rootdir="/var/run/mn/$host/root"
38 if [ -d $rootdir -a -x $rootdir/bin/bash ]; then
39 cmd="'cd `pwd`; exec $cmd'"
40 cmd="chroot $rootdir /bin/bash -c $cmd"
43 cmd="exec sudo mnexec $cg -a $pid $cmd"