I now have a chance to say "READ THE FRICKING MANUAL" 🙂
777 decimal = 1411 OCTAL.
chmod() and mkdir() need the permissions to be specified as OCTAL not decimal if you want to use the normal chmod numbers.
0777 is octal, 777 is decimal
0777 octal = 511 decimal
How did you miss that one Dale?
HalfaBee