0

Im trying to iterate in loop after the subprocess call but getting the error

from subprocess import PIPE, call
cmd1 = 'find ./ -maxdepth 1 -name *.xml -type f -mtime +1'
result = call(cmd1,shell=True)
resultlist = result.split('/n')
for fname in resultlist:
    print(FileName - ':fname)

resultlist = result.split('/n') AttributeError: 'int' object has no attribute 'split'

  • `subprocess.call()` is not appropriate if you want the actual output from the command - all it gives you is the exit code. Try `.run()` or `.check_output()` instead. – jasonharper Aug 09 '21 at 03:59
  • Hi Thanks for your reply, I'm using python 2.7 in the server it doesn't support run(). Pls give me some sample for check_output() as I'm new to Python – ajaay kannan Vr Aug 09 '21 at 04:30

0 Answers0