Skip to contentSkip to conversation

nsenter: passing command arguments

DISCUSSION Nicolas 3 participants 4 messages Apr 17, 2014 – Apr 22, 2014 Util-Linux package

lore
Share & tools
lore

Nicolas

author
#0 lore raw

Hi,
I'm struggling with nsenter to call commands with options because they are caught by nsenter and complain this is an invalid option.

How can I pass any arbitrary argument ?

Thanks for reading,
Nicolas

```
$ nsenter --target $PID --mount --uts --ipc --net --pid ls -a
nsenter: invalid option -- 'a'

Usage:
 nsenter [options] <program> [args...]

Options:
 -t, --target <pid>     target process to get namespaces from
 -m, --mount [=<file>]  enter mount namespace
 -u, --uts   [=<file>]  enter UTS namespace (hostname etc)
 -i, --ipc   [=<file>]  enter System V IPC namespace
 -n, --net   [=<file>]  enter network namespace
 -p, --pid   [=<file>]  enter pid namespace
 -U, --user  [=<file>]  enter user namespace
 -S, --setuid <uid>     set uid in user namespace
 -G, --setgid <gid>     set gid in user namespace
 -r, --root  [=<dir>]   set the root directory
 -w, --wd    [=<dir>]   set the working directory
 -F, --no-fork          do not fork before exec'ing <program>

 -h, --help     display this help and exit
 -V, --version  output version information and exit

For more details see nsenter(1).

```
Signature · 5 lines
Nicolas Delaby · Software Engineer · ezeep.com

ezeep GmbH · Ohlauer Str. 43 · 10999 Berlin · Germany

Registry Court: Charlottenburg · HRB133318 · Managing partner: Sascha Kellert
#1 lore raw
Quoted 4 lines · Nicolas

Hi,
I'm struggling with nsenter to call commands with options because they are caught by nsenter and complain this is an invalid option.

Quoted 8 lines

How can I pass any arbitrary argument ?

Thanks for reading,
Nicolas

```

$ nsenter --target $PID --mount --uts --ipc --net --pid ls -a
nsenter: invalid option -- 'a'

Use '--' to tell nsenter to stop option parsing:

  $ nsenter --target $PID --mount --uts --ipc --net --pid -- ls -a

Although I think this can be considered a bug; nsenter should do this automatically when seeing the first non-option.

Have a nice day,
Berny

maintainer
#2 lore raw
Quoted 14 lines · Bernhard Voelker
Quoted 4 lines · Nicolas

Hi,
I'm struggling with nsenter to call commands with options because they are caught by nsenter and complain this is an invalid option.

Quoted 8 lines

How can I pass any arbitrary argument ?

Thanks for reading,
Nicolas

```

$ nsenter --target $PID --mount --uts --ipc --net --pid ls -a
nsenter: invalid option -- 'a'
Quoted 5 lines

Use '--' to tell nsenter to stop option parsing:

  $ nsenter --target $PID --mount --uts --ipc --net --pid -- ls -a

Although I think this can be considered a bug; nsenter should do this automatically when seeing the first non-option.

Yep, fixed (also in unshare).

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
author
#3 lore raw
In reply to Bernhard Voelker
Quoted 14 lines · Bernhard Voelker
Quoted 4 lines · Nicolas

Hi,
I'm struggling with nsenter to call commands with options because they are caught by nsenter and complain this is an invalid option.

Quoted 8 lines

How can I pass any arbitrary argument ?

Thanks for reading,
Nicolas

```

$ nsenter --target $PID --mount --uts --ipc --net --pid ls -a
nsenter: invalid option -- 'a'
Quoted 5 lines

Use '--' to tell nsenter to stop option parsing:

   $ nsenter --target $PID --mount --uts --ipc --net --pid -- ls -a

Although I think this can be considered a bug; nsenter should do this automatically when seeing the first non-option.

Thank you Bernhard,

It Worked like a charm :)
Have a nice day too.

Nicolas

Signature · 5 lines
Nicolas Delaby · Software Engineer · ezeep.com

ezeep GmbH · Ohlauer Str. 43 · 10999 Berlin · Germany

Registry Court: Charlottenburg · HRB133318 · Managing partner: Sascha Kellert