Python Forum
Python Paramiko mkdir command overwriting existing folder. How can i stop that? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Python Paramiko mkdir command overwriting existing folder. How can i stop that? (/thread-28759.html)



Python Paramiko mkdir command overwriting existing folder. How can i stop that? - therenaydin - Aug-02-2020

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')



RE: Python Paramiko mkdir command overwriting existing folder. How can i stop that? - therenaydin - Aug-02-2020

No replies sad