diff --git a/mininet/node.py b/mininet/node.py index 3c61393..371c0c0 100644 --- a/mininet/node.py +++ b/mininet/node.py @@ -383,23 +383,23 @@ class Node( object ): 'mncmd': [ 'mnexec', '-da', str( self.pid ) ] } defaults.update( kwargs ) + shell = defaults.pop( 'shell', False ) if len( args ) == 1: if isinstance( args[ 0 ], list ): # popen([cmd, arg1, arg2...]) cmd = args[ 0 ] elif isinstance( args[ 0 ], BaseString ): # popen("cmd arg1 arg2...") - cmd = args[ 0 ].split() + cmd = [ args[ 0 ] ] if shell else args[ 0 ].split() else: raise Exception( 'popen() requires a string or list' ) elif len( args ) > 0: # popen( cmd, arg1, arg2... ) cmd = list( args ) + if shell: + cmd = [ os.environ[ 'SHELL' ], '-c' ] + [ ' '.join( cmd ) ] # Attach to our namespace using mnexec -a cmd = defaults.pop( 'mncmd' ) + cmd - # Shell requires a string, not a list! - if defaults.get( 'shell', False ): - cmd = ' '.join( cmd ) popen = self._popen( cmd, **defaults ) return popen