Jul-18-2019, 03:48 PM
Below is the script I have with the command you suggested.
So when I run the python as you can see there is no error. But the command did not return any output. And if you look at the command being printed its different than what is desired.
Output:import paramiko
from subprocess import list2cmdline
import shlex
client=paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
cmd = list2cmdline(shlex.split("find /OVS -wholename '*VirtualMachines/*/vm.cfg' -exec grep -H 'simple_' {} \; 2>/dev/null | awk {'print $3'} | tr -d \"'\""))
client.connect('XX.XX.XX.XX',22, username='XXXX', password='XXXX')
output=""
stdin, stdout, stderr = client.exec_command(cmd)
print "ssh succuessful. Closing connection"
stdout=stdout.readlines()
client.close()
print "Connection closed"
print stdout
print cmd
for line in stdout:
output=output+line
if output!="":
print output
else:
print "There was no output for this command"
So when I run the python as you can see there is no error. But the command did not return any output. And if you look at the command being printed its different than what is desired.
Error:ssh succuessful. Closing connection
Connection closed
[]
find /OVS -wholename *VirtualMachines/*/vm.cfg -exec grep -H simple_ {} ; 2>/dev/null | awk "{print $3}" | tr -d '
There was no output for this command