Skip to content

Instantly share code, notes, and snippets.

@morris821028
Created March 11, 2016 01:40
Show Gist options
  • Save morris821028/4e99220726a9221cd97e to your computer and use it in GitHub Desktop.
Save morris821028/4e99220726a9221cd97e to your computer and use it in GitHub Desktop.
TA work: add student account on server
import os
student = open('students')
for line in student.readlines():
line = line[:-1]
print line
cmd = "useradd -m -s /bin/bash -d /home/pp2016/%s %s" % (line, line)
psw = "echo %s:%s | chpasswd" % (line, line)
print cmd
print psw
# assert os.system(cmd) == 0
# assert os.system(psw) == 0
bash = "chsh -s /bin/bash %s" % line
print bash
assert os.system(bash) == 0
B01505025
B01505026
B02902062
B02902087
B02902091
B01902027
B01902059
B01902103
R03921053
R04922067
R04922075
R04922080
R04922106
R04922133
R04944035
60447007S
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment