Issue
I'm using the following code to run commands on a remote machine via paramiko.
commands = [[r"1st commands goes in here", "remote path", "localpath"],
[r"2nd commands goes in here", "remote path", "localpath"]]
for command in commands:
# create a new session
try:
server = ShellHandler(ip_address, "admin", admin_pw)
open_ftp = server.ftp()
except:
sys.exit("something went wrong, please try again")
cmd = server.execute("cd /home/admin/automated")
cmd = server.execute(command[0])
open_ftp.get(command[1], command[2])
# end the current session
avamar.ssh.close()
open_ftp.close()
I'm creating a new connection for each command and redirecting the output to a file and downloading that file using pramiko .get
I'm getting inconsistent output from this code, sometimes it works just fine and grabs the files and sometimes it gives this error:
Traceback (most recent call last):
File "Z:\gdrive\python\projects\automation\alpha\loop.py", line 726, in <module>
open_ftp.get(remote_path, local_path)
File "C:\Users\adam4\AppData\Local\Programs\Python\Python38-32\lib\site-packages\paramiko\sftp_client.py", line 811, in get
size = self.getfo(remotepath, fl, callback, prefetch)
File "C:\Users\adam4\AppData\Local\Programs\Python\Python38-32\lib\site-packages\paramiko\sftp_client.py", line 783, in getfo
with self.open(remotepath, "rb") as fr:
File "C:\Users\adam4\AppData\Local\Programs\Python\Python38-32\lib\site-packages\paramiko\sftp_client.py", line 372, in open
t, msg = self._request(CMD_OPEN, filename, imode, attrblock)
File "C:\Users\adam4\AppData\Local\Programs\Python\Python38-32\lib\site-packages\paramiko\sftp_client.py", line 822, in _request
return self._read_response(num)
File "C:\Users\adam4\AppData\Local\Programs\Python\Python38-32\lib\site-packages\paramiko\sftp_client.py", line 874, in _read_response
self._convert_status(msg)
File "C:\Users\adam4\AppData\Local\Programs\Python\Python38-32\lib\site-packages\paramiko\sftp_client.py", line 905, in _convert_status
raise IOError(errno.EACCES, text)
PermissionError: [Errno 13] Permission denied
any idea what's wrong here!
Solution
this error has to do with file permission on your machine.
Answered By - ZZZ
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.