def get_all_connected(host, port, user, password):
command = 'sshpass -p' + password + ' ssh -q -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile /dev/null" ' + user + '@' + host + ' netstat -tn | grep ' + str(port) + ' | grep ESTABLISHED | wc -l'
- #print command
output = check_output(shlex.split(command), shell=False)
return int(output)
payload = {'from':userdata['id'], 'type':'request', 'command':'ssh'}
client.publish(userdata['to'], str(payload))
elif userdata['action'] == 'list':
- #timer = threading.Timer(20, timeout)
- #timer.start()
payload = {'from':userdata['id'], 'type':'request', 'command':'list'}
client.publish(userdata['to'], str(payload))
- #print '-' * 30
print'{0}\t\t{1}'.format(' Device ID ', 'Data')
print '-' * 30
mac = hex(get_mac())
return '{:0>12}'.format(mac[2:-1])
-#def timeout():
-# print 'timeout'
-# client.disconnect()
-# sys.exit(0)
-#
-
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Choose an avaiable port and run ssh.', add_help=False)
parser.add_argument('--help', action='help')