Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #must be run from server with connections to all servers on which accounts will b$
- #to run bash commands, you need to import them
- #v3 replacement for commands
- import subprocess
- #regex
- import re
- #get username from inputer
- username=input("What username do you want to create?")
- print(username)
- #check username availability - original thoughts - programatically incorrect
- #checkavail=grep username /etc/passwd
- #print(checkavail)
- # if checkavail!=""
- # print(username) is already in use
- # multiacc.py
- # else: (might be elif)
- # print(username) is available
- with open('/etc/passwd', 'r') as origin_file:
- for line in origin_file:
- line = re.findall(r'(username)', line)
- if line:
- line = line[0].split(':')[0]
- print (line)
- # print (origin_file)
- #suggested in chat by altendky
- #with open('/etc/passwd') as f: for line in f: username = line.split(':')[0]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement