First, using input() not recommended, as it expects the user to type the correct Python expressions. Use raw_input() :
app = raw_input('Name of the application: ')
Further, the return value from system('pidof') not a PID code, it is the exit code from the pidof command, i.e. zero on success, and not zero on error. You want to capture pidof output .
import subprocess
The next line does not contain a space after grep and would lead to a command like grep1234 . Using the % line format operator will make this a little easier:
os.system('top -d 30 | grep %d > test.txt' % (pid))
The third line is badly quoted and should lead to a syntax error. Watch out for single quotes inside single quotes.
os.system("awk '{print $10, $11}' test.txt > test2.txt")
source share