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'

2
  • 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. Commented Aug 9, 2021 at 3: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 Commented Aug 9, 2021 at 4:30

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.