Python code useful for following :
==> Connect to remote desktop machine(Linux/ Ubuntu based systems)
==> Copy the files to from local to remote machine
==> Copy the files to from remote machine to local machine
==>Executing commands on Remote machine from local machine
==>To take screenshot of remote machine
Note: I have used config.json file, for future modifications
{
"modelName": "Desktop",
"Local_Machine_Path": "C:\\Bhagyasree\\images\\",
"Linux_Remote_Machine_Path": "/home/Narendra/ntest/",
"Linux_Remote_Machine_IP_Addr": "192.10.14.3",
"Linux_Remote_Machine_User_Name": "narendrab",
"Linux_Remote_Machine_Pass_word": "Nanna@786",
}
==> Connect to remote desktop machine(Linux/ Ubuntu based systems)
==> Copy the files to from local to remote machine
==> Copy the files to from remote machine to local machine
==>Executing commands on Remote machine from local machine
==>To take screenshot of remote machine
Note: I have used config.json file, for future modifications
{
"modelName": "Desktop",
"Local_Machine_Path": "C:\\Bhagyasree\\images\\",
"Linux_Remote_Machine_Path": "/home/Narendra/ntest/",
"Linux_Remote_Machine_IP_Addr": "192.10.14.3",
"Linux_Remote_Machine_User_Name": "narendrab",
"Linux_Remote_Machine_Pass_word": "Nanna@786",
}
ip_addr = Linux_Remote_Machine_IP_Addr User_Name = Linux_Remote_Machine_User_Name Pass_word = Linux_Remote_Machine_Pass_word ssh_client = paramiko.SSHClient() ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) print("Please wait while connecting to host machine/Remote server") ssh_client.connect(ip_addr, username=User_Name, password=Pass_word) print("Please wait, executing command on remote machine") remote_path = Linux_Remote_Machine_Path local_path = Local_Machine_Path path = Linux_Remote_Machine_Path # image_name = "Desktop"
image_name = "Desktop"
cmd1 = "import -window root -display :0 " + path + "{}.png".format(image_name) stdin, stdout, stderr = ssh_client.exec_command(cmd1) host = Local_Machine_Path target = Linux_Remote_Machine_Path image_name = "Desktop.png"sftp = ssh_client.open_sftp() sftp.get(target + image_name, host + image_name) print("file successfully copied") ssh_client.close()
No comments:
Post a Comment