Coder Social home page Coder Social logo

pyip's Introduction

One-Off Coder Logo

Intro

A simple Python program that may be used as a service for Linux and Windows to get your external (public) IP and send it to yourself. Use at your own risk as password parameter for the email account being used has to be passed in unencrypted. The following is a printout of the help.

usage: IP Locator [-h] [-u URL] [-m MAX_EMAILS] [-s SLEEP] -e EMAIL -p
                  PASSWORD [--subject SUBJECT] [--version]

optional arguments:
  -h, --help            show this help message and exit
  -u URL, --url URL     the URL of the site to get your external IP (default: https://myexternalip.com/raw)
                            Other sites that may work.
                                - https://www.ipchicken.com
                                - https://myexternalip.com/raw
                            
  -m MAX_EMAILS, --max_emails MAX_EMAILS
                        maximum emails; set to -1 for indefinite (default: -1)
  -s SLEEP, --sleep SLEEP
                        seconds between checking/sending IP in email (default: 3600)
  -e EMAIL, --email EMAIL
                        gmail email address
  -p PASSWORD, --password PASSWORD
                        gmail email password
  --subject SUBJECT     email subject line modifier (default: IP Address)
  --version             show program's version number and exit

One-Off Coder, http://www.oneoffcoder.com

Note that only the email -e and password -p are required, and that this program has only been tested against a gmail account. A quick and dirty example of using this program is as follows (of course, substitute the email and password values with your own).

python ip.py -e [email protected] -p codebreaker

Installation

CentOS Linux

# copy python file
sudo cp ip.py /usr/bin
sudo chmod 600 /usr/bin/ip.py

# copy service file
# make sure you modify ExecStart with the appropriate email and password
# make sure the path to python is absolute e.g. /home/super/anaconda3/bin/python
sudo cp pyip.service /lib/systemd/system
sudo nano /lib/systemd/system/pyip.service
sudo chmod 600 /lib/systemd/system/pyip.service 

# to enable, start, stop, etc.. the service
sudo systemctl daemon-reload
sudo systemctl enable pyip.service
sudo systemctl start pyip.service
sudo systemctl status pyip.service
sudo systemctl stop pyip.service
sudo systemctl restart pyip.service

Windows

On Windows, use the sc command.

sc create PyIP binPath="C:\ProgramData\Anaconda3\python.exe C:\dev\ip.py -e [email protected] -p codebreaker"
sc start PyIP
sc delete PyIP

References

Citation

@misc{oneoffcoder_ip_locator_2019, 
title={External IP locator using Python for Linux and Windows}, 
url={https://github.com/oneoffcoder/pyip}, 
journal={GitHub},
author={One-Off Coder}, 
year={2019}, 
month={Aug}}

Copyright Stuff

Copyright 2019 One-Off Coder

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Contact

One-Off Coder

pyip's People

Contributors

vangj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.