Python Forum

Full Version: Python Paramiko mkdir command overwriting existing folder. How can i stop that?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm trying to create a register system based on server. Sending directories to my server with their name. But if you try to register with an existing username, you can. I don't want that... Tried that before in my own computer with os.mkdir() and worked perfectly. But when i remote control my server and use mkdir that just overwrites the old one. How can i fix that? Here is my code;
    try:
                stdin, stdout, stderr = ssh.exec_command('cd Server_Data;cd Users;mkdir '+userName)
            except:
                print("There is a registered user with the same name. Please choose another one.")
            else:
                savedUser = userName
                stdin, stdout, stderr = ssh.exec_command('cd Server_Data;cd Users;cd '+userName+';echo ' + userName + ' > rUser.txt')
                savedPass = password
                stdin, stdout, stderr = ssh.exec_command('cd Server_Data;cd Users;cd '+userName+';echo ' + password + ' > rPassw.txt')
No replies sad