blob: 8bcd141bb29a34ec9e870f0d4a4513e0af35c017 [file] [log] [blame]
Masayoshi Kobayashi72dc5882013-04-06 06:47:50 +00001#!/bin/bash
2
3# Attach to a Mininet host and run a command
4
5if [ -z $1 ]; then
6 echo "usage: $0 host cmd [args...]"
7 exit 1
8else
9 host=$1
10fi
11
12pid=`pgrep -f ${host}.banner`
13if [ "$pid" == "" ]; then
14 echo "Could not find Mininet host $host"
15 exit 2
16fi
17
18if [ -z $2 ]; then
19 cmd='bash'
20else
21 shift
22 cmd=$*
23fi
24
25cgroup=/sys/fs/cgroup/cpu/$host
26if [ -d "$cgroup" ]; then
27 cg="-g $host"
28fi
29
30exec sudo mnexec -a $pid $cg $cmd