Every now and again, I need to start the Django development server, and have it viewable by other machines on my network, as described here:
http://docs.djangoproject.com/en/dev/ref/django-admin/#runserver
My machine’s IP address tends to change every now and again, so I’d like to have a little shell alias or something that spits out the manage.py command with my machine’s current IP address, maybe like this:
python manage.py runserver $(COMMAND TO FIND MY MACHINE’S IP ADDRESS GOES HERE):8000
This is a quick and dirty way, that works under OSX
Basically get all interfaces with an IPV4 address, skip localhost and then get the first interface.
Also, use path to ifconfig. I have seen to many shell script brake when used from ex. cron because of PATH failure.
Simple Command to fine IP Address with default interface.
Tested on All Unix OS
Here a solution to find the current IP address:
tested on Mac only.
You might already be aware, but running
makes your machine visible to everyone on the network.
Is there a reason you'd need to specify your IP?
Folks are using character counts to pull the right columns from the ip address line, but using spaces as a delim makes this more scalable to different length ip addresses...
Thi should work as well as other commands I've already seen:
I̶ ̶t̶h̶i̶n̶k̶ ̶y̶o̶u̶ ̶c̶a̶n̶ ̶a̶l̶s̶o̶ ̶w̶r̶i̶t̶e̶:̶
̶ ̶ ̶ ̶h̶o̶s̶t̶n̶a̶m̶e̶ ̶-̶I̶ ̶|̶ ̶c̶u̶t̶ ̶-̶d̶'̶ ̶'̶ ̶-̶f̶1̶ ̶