Trying to add user with python fabric script.
uid = prompt("Enter username:")
eid = prompt("Enter user's email address:")
password = generate_passwd()
run('adduser -g vpn -c %s %s') % (eid, uid)
run("echo -e '%s\n' | passwd %s") % (password, uid)
print (password)
Error:
File "/tmp/hardway/fabfile.py", line 56, in addvpnuser
run('adduser -g vpn -c %s %s') % (eid, uid)
TypeError: not all arguments converted during string formatting
Any idea what i’m doing wrong. thanks in advance.
The problem is that you’re placing the string interpolation in the wrong place; it has to be directly after the string and not outside the parens. (This is not specific to fabric, by the way.)
So
instead of
and
instead of