Curiosity › Technology › Computers and Smartphones › What is the fastest way to know my IP address from the command line? › Reply To: What is the fastest way to know my IP address from the command line?
I also tried to do this with Python. I found out that ipinfo.io returns a JSON object for any requests. If you have Python installed in your Windows machine, maybe this will help you display your public IP address in the command line.
import requests import json r = requests.get('http://ipinfo.io/') json_data = r.json() print json_data['ip']
If you want to copy the IP to your clipboard, all you have to do is to use the
| clip operator. E.g:
python ip.py | clip
Pretty simple. :)
Additionally, you can add a batch file to get it done quickly!
@echo off echo Your Public IP python ipfind.py set /P choice = "Do you want to copy it to your clipboard [type 'y' or terminate using 'CTRL+C'] ? " if "%choice%" == "y" goto copy_stuff_to_clipboard :copy_stuff_to_clipboard python ipfind.py | clip pause