Python Forum
How to run unix command in python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to run unix command in python
#2
subprocess.check_output

command = "find /user/s/balaji/ -mtime +20 -type f | grep -v .ksh | grep -v .txt".split()

output = subprocess.check_output(command).decode('utf-8')

ouptut_list = output.split('\n') # every output line will be a list element
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Messages In This Thread
How to run unix command in python - by soubalaji - Jan-11-2018, 05:17 AM
RE: How to run unix command in python - by wavic - Jan-11-2018, 07:16 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  unable to run unix command using spur purnima1 11 7,124 Sep-07-2018, 07:57 AM
Last Post: purnima1

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020