Mapping network drive with paramiko

  paramiko, python, python-3.x, ssh

I’m trying to map a network drive on a windows machine from linux using Paramiko.
I use

_, stdout, stderr = client.exec_command(r"net use <letter>: <path>")

but it does not map the drive successfully (the drive’s status is Unavailable):

PS C:Usersuser> net use
New connections will be remembered.


Status       Local     Remote                    Network

-------------------------------------------------------------------------------
Unavailable  <letter>:        <path>
                                                Microsoft Windows Network
The command completed successfully.

Looking for a solution online, there were a lot of suggestions to wait for exit status, so I did:

_, stdout, stderr = client.exec_command(r"net use <letter>: <path>")
rc = stdout.channel.recv_exit_status()

And the result was the same.

How can it be done?

Thanks!

Source: Python-3x Questions

LEAVE A COMMENT