0
import paramiko
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect('hostname', username='test1234', password='test')
path = ['/home/test/', '/home/test1/','/home/test3/']
sftp = client.open_sftp()
check = 'tail -f /home/test/logs/check.out'
for filename in sftp.listdir(path):
    if filename.endswith('.txt'):
        h = path + filename 
        stdin,stdout,stderr = client.exec_command('%s && %s | grep -i "Connection time out"' %path %check)
        stdout = = revout.read().decode().splitlines()
        print stdout

i tried to pass 2 string at a time to exec_command. But it's not working. how to pass 2 string at a time?

2
  • What if you use str.format? Commented Apr 17, 2018 at 11:43
  • script is not executing prompting to next line. No error as well. Commented Apr 17, 2018 at 11:51

1 Answer 1

1

You can either use

'%s && %s | grep -i "Connection time out"' % (path,check)

or Python 3's .format

'{0} && {1} | grep -i "Connection time out"'.format(path,check)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.