Advertisement
TheGerman

Synaccess NetBooter Date/Time update script (no NTP devices)

Jun 27th, 2018
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.31 KB | None | 0 0
  1. ###############################################################
  2. #
  3. #   Synaccess Networks, Inc.  (www.synaccess-net.com)
  4. #   Jan. 6th, 2013
  5. #   Python Script Example 1  
  6. #   for NP series.
  7. #   https://www.synaccess-net.com/support/
  8. #   https://www.synaccess-net.com/s/np_rb.py
  9. ################################################################
  10.  
  11. import socket
  12. import time
  13. import sys
  14. import datetime
  15.  
  16.  
  17. def connect(ip_value, port_value):
  18.  
  19.     HOST = str(ip_value)
  20.     PORT = int(port_value)
  21.     sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  22.     sock.connect((HOST, PORT))
  23.  
  24.  
  25.     #print('{:%m/%d/%Y}'.format(datetime.datetime.now()))
  26.     #print('{:%H:%M:%S}'.format(datetime.datetime.now()))
  27.  
  28.     time.sleep(0.1)                                                         #use time.sleep to give delay and netBooter time to process
  29.  
  30.     sock.send('\r')                                                         #send \r to start at beginning of line
  31.     time.sleep(0.5)
  32.     sock.send('login\r')
  33.     time.sleep(0.5)
  34.     sock.send('admin\r')                # username
  35.     time.sleep(0.5)
  36.     sock.send('admin\r')                # password
  37.     time.sleep(0.5)
  38.     sock.send('setup\r')
  39.     time.sleep(0.5)
  40.     sock.send('2\r')
  41.     time.sleep(1.0)
  42.     sock.send('2\r')
  43.     time.sleep(1.0)
  44.     sock.send('{:%m/%d/%Y}\r'.format(datetime.datetime.now()))
  45.     time.sleep(2.0)
  46.     sock.send('3\r')
  47.     time.sleep(2.0)
  48.     sock.send('{:%H:%M:%S}\r'.format(datetime.datetime.now()))
  49.     time.sleep(2.0)
  50.     sock.send('s\r')
  51.     time.sleep(0.5)
  52.     sock.send('q\r')
  53.     time.sleep(0.5)
  54.     sock.send('s\r')
  55.     time.sleep(0.5)
  56.     sock.send('q\r')
  57.     time.sleep(0.5)
  58.     sock.send('logout\r')
  59.  
  60.     #recv = sock.recv(8192)                 #receive data from session
  61.     #print(recv)                            #print data received
  62.  
  63.     time.sleep(0.1)
  64.  
  65.     sock.close()
  66.  
  67.  
  68. def main():
  69.     if len(sys.argv) !=5:
  70.         print('\r\n')
  71.         print('Example:> np_term.py -i 192.168.1.100 -p 23\r\n')
  72.         print('          np_term.py -i Unit_IP_Addr  -p Telnet_port# \r\n')
  73.         sys.exit(1)
  74.    
  75.     ip = sys.argv[1]                            #For -i option in command line
  76.     ip_value = sys.argv[2]                      #IP address value entered
  77.     port = sys.argv[3]                          #For -p option in command line
  78.     port_value = sys.argv[4]                    #Port number entered
  79.     if ip == '-i' and port == '-p':             #Check that the command line uses both -i and -p for valid connection
  80.         connect(ip_value,port_value)           
  81.    
  82.        
  83. if __name__ == '__main__':
  84.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement