Hi
I am trying to execute a sed command inside paramiko which finds and deletes the particular string from a file
But sed command doesnt work inside paramiko python
machine=qwe
dssh = paramiko.SSHClient()
dssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
dssh.connect( host, username='xxx', password='123', timeout=120)
except Exception as e:
ln="SSH to machine:%s FAILED" % ( machine )
print_log(ln)
exit_status()
grpRem = 'sed -i -E "/paste=used//g" /etc/gr.txt > /etc/tempFile'
stdin, stdout, stderr = dssh.exec_command( grpRem )
if stdout.channel.recv_exit_status() != 0:
err="cmd=%s FAILED" % (grpRem)
print_log(grpRem)
dssh.close()
exit_status()
else:
print "Copying temp file back to original file"
#fileMv = 'mv /etc/tempFile /etc/gr.txt'
else:
print "paste=used not found.."
else:
print "the system is inside else loop"
dssh.close()
The file is:
cat gr.txt | grep paste
i have a paste=used so that it wont be available for anyone
I do not have a paste=used
My expected output should be (paste=used should be deleted)
cat gr.txt
i have a so that it wont be available for anyone
I do not have a
Please help
---------- Post updated at 06:00 AM ---------- Previous update was at 05:26 AM ----------
I tried with get_pty=True even then no luck seen..
grpRem = 'sed -i -E "/xmon=on//g" /etc/grub2.cfg > /etc/tempFile,get_pty=True'
Please help