Reliance Broadband Auto Login Script - Syntax Error When Running on Windows
Question: I am using Reliance Broadband which has web based login for accessing
internet. It gets log-off every 24hrs, so I have to sign in again.

I came across a [PYTHON script](https://github.com/zyxware/reliance-auto-
login-script), which keeps checking connection and keeps the connection alive.

Somehow When I run it on windows after installing the latest Python version, I
get following syntax error.

    
    
    C:\Documents and Settings\CS\Desktop>reliance-login.py
    
      File "C:\Documents and Settings\CS\Desktop\reliance-login.py", line 48
        if debug: print "Testing"
                                ^
    SyntaxError: invalid syntax
    

Can anyone please check and let me know what exactly is the issue?

=====

Thanks sr2222, I tried 2to3, after removing all + n - ... I am still getting
some error.

Following is the script afer 2to3.. can you please run it on your machine n
help in fixing the error.

    
    
                #!/usr/bin/env python
                # encoding: utf-8
                """
                # Reliance Login Script for Python 2.x v1.0
                #
                # Copyright (c) 2009 Kunal Dua, http://www.kunaldua.com/blog/?p=330
                # Copyright (c) 2012 Anoop John, http://www.zyxware.com
                #
                # This program is free software; you can redistribute it and/or modify
                # it under the terms of the GNU General Public License as published by
                # the Free Software Foundation; version 2 of the License.
                #
                # This program is distributed in the hope that it will be useful,
                # but WITHOUT ANY WARRANTY; without even the implied warranty of
                # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
                # GNU General Public License for more details.
                """
    
                import urllib.request, urllib.error, urllib.parse, urllib, http.cookiejar, time, re, sys
    
                username = 'username'
                password = 'password'
                     req_headers = {
                         'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; U; ru; rv:5.0.1.6) Gecko/20110501 Firefox/5.0.1 Firefox/5.0.1'
                     }
                request = urllib.request.Request(url, headers=req_headers)
                     if not opener:
                        jar = http.cookiejar.FileCookieJar("cookies")
                        opener = urllib.request.build_opener(urllib2.HTTPCookieProcessor(jar))
                     response = opener.open(request, data)
                     code = response.code
                     headers = response.headers
    
                 def is_internet_on():
                     '''test if the machine is connected to the internet'''
                    if debug: print("Testing")
                     try:
                         code, headers, html, opener = get_url('http://74.125.113.99', timeout=10)
                        if debug: print(html)
                         if re.search('google.com', html):
                             return True
                         else:
                             return False
                     except:
                        if debug: print("Error")
                         return False
                     return False
    
                 def internet_connect():
                     '''try to connect to the internet'''
                     code, headers, html, cur_opener = get_url("http://10.239.89.15/reliance/startportal_isg.do", timeout=10)
                    if debug: print(html)
                    login_data = urllib.parse.urlencode({'userId' : username, 'password' : password, 'action' : 'doLoginSubmit'})
                     code, headers, html, cur_opener = get_url('http://10.239.89.15/reliance/login.do', data=login_data, opener=cur_opener)
                    if debug: print(html)
    
                 def internet_disconnect():
                     '''try to disconnect from the internet'''
                     code, headers, html, cur_opener = get_url('http://10.239.89.15/reliance/login.do', timeout=10)
                    if debug: print(html)
                     code, headers, html, cur_opener = get_url('http://10.239.89.15/reliance/logout.do', opener=cur_opener)
                    if debug: print(html)
    
                 def internet_keep_alive():
                     '''login and keep the connection live'''
                     while True:
                         if not is_internet_on():
                             internet_connect()
                            if debug: print("Not connected")
                         else:
                            if debug: print("Connected")
                             pass
                         time.sleep(check_interval)
    
                 def print_usage():
                    print("Reliance Netconnect AutoLogin")
                    print("-----------------------------")
                    print("usage:" + sys.argv[0] + " [login|logout]\n")
                    print("If there are no arguments it runs in an infinite loop and will try to remain connected to the internet.")
    
                 keep_alive = True
                 if (len(sys.argv) > 1): 
    


Answer: Did you download Python 2 or Python 3? That's Python 2.X print syntax, if you
have a Python 3 interpreter, you will see that error. That script is probably
written in Python 2.X. You can either download a different interpreter or run
the 2to3.py script on the source of your stay-alive script to get it working
under Python 3.

Also, wow, there are ISPs that still do that? Sorry you are stuck with that.

