How to avoid sudo prompt when configured with --enable-sudo flag

95 views
Skip to first unread message

Bill Tao

unread,
May 2, 2023, 3:39:21 AM5/2/23
to ns-3-users
Hi.

I am setting up an experiment as an ns-3 campaign where I am using the real-time mode to provide an emulated transport network for some real software. 

Because of the real time configuration, I want to run the experiment multiple times to improve statistical significance, and to automate this I try to set up a bash script that calls "./ns3 run" multiple times. 

However, at the moment I can't really automate it because each time I execute "./ns3 run", I am prompted with the password by sudo. Also I have to stay in sudo mode because my campaign works with tap bridges too.

So is there a way to work around this?

Thanks.
Regards,
Bill.

Gabriel Ferreira

unread,
May 2, 2023, 2:22:10 PM5/2/23
to ns-3-users
Yes, there is. 

You can define SUDO_PASSWORD with your password (which sounds bad, but is meant for testing). 
Or configure with enable sudo, to enable the sudo bit on the executable and always run it as a superuser, without having to add any password. 

Bill Tao

unread,
May 2, 2023, 9:05:48 PM5/2/23
to ns-3-users
Thank you, Gabriel.

For clarity, I believe this (Approach 2 in the link) is what you mean with defining a SUDO_PASSWORD environment variable?

Also, I believe your 2nd suggestion is how I attempted it, i.e. configure with the --enable-sudo flag, but I am still prompted with the password at the beginning of every run. Am I missing something? I am still calling "./ns3 run ..." as regular user though, i.e. without sudo.

Thanks

Bill

Tommaso Pecorella

unread,
May 3, 2023, 2:22:26 PM5/3/23
to ns-3-users
Hi,

the best option is to add the command to the sudoers, see for example this tutorial:

Bill Tao

unread,
May 17, 2023, 2:16:20 AM5/17/23
to ns-3-users
Thank you, Tommaso.
Reply all
Reply to author
Forward
0 new messages