#!/bin/bash # Attach to a Mininet host and run a command if [ -z $1 ]; then echo "usage: $0 host cmd [args...]" exit 1 else host=$1 fi if [ -z $2 ]; then cmd='bash' else shift cmd=$* fi # We could do this in this script, and we may want to eventually, # but for now we'll use mnexec to attach to the host's cgroup cgroup=/sys/fs/cgroup/cpu/$host if [ -d "$cgroup" ]; then cg="mnexec -g $host" fi exec sudo ip netns exec $host $cg $cmd