Month: February 2014

Auto Enter Password For sudo Command

Normally using sudo will request the user a password after executing it but sometimes we might need to run a command with sudo from a script(bash script) or from a program. To auto enter a password for a script that will execute a sudo command you will need to do it like this in your script:

echo [password] | sudo -S echo "Sudo with auto enter of password"

Just replace the “[password]” with your actual password. Notice that we have “-S” as the option we pass for the sudo command. This option enables sudo to read the password from stdin where we have echoed our password.

Just an opinion but if you find yourself needing to auto enter a password in sudo command then maybe you should consider running it as a root user instead.

Access Django Development Server Remotely

By default Django development server will only be accessible through the local machine( If you want to access the server remotely then you need to run the the development server with your IP as an argument:

python runserver [your-ip-here]:8000

Change the “[your-ip-here]” to your actual IP. If you IP address is then you will need to run the server using this:

python runserver

If you have multiple network configured or you want the server to be automatically available on what your IP now currently is. Then enter as your IP, like this:

python runserver

This will bind the development server of Django on all available network/IP address. Then you will the see same message when you use just use python runserver  upon successfully creating the server but instead of you will see a, then you will now be able to access your server remotely.

Validating models...
0 errors found
February 01, 2014 - 10:13:18
Django version 1.5.1, using settings mysite.settings
Development server is running at
Quit the server with CONTROL-C.

Warning: This server is only meant for development use so you must not use this as a production solution. This is also discouraged by Django team.

© 2017 James Baltar

Theme by Anders NorenUp ↑