import os os.getcwd() os.listdir(os.curdir) os.mkdir('junkdir') 'junkdir' in os.listdir(os.curdir) fp = open('junk.txt', 'w') # first create an empty file fp.close() fp = open('junk.txt', 'w') import subprocess subprocess.call('chmod +x rst2py.py', shell=True) output = subprocess.check_output(['ls','-all','-h']) print(output) import urllib url = urllib.FancyURLopener() link = 'http://www.ster.kuleuven.be/~pieterd/some_program.f' myfile,msg = url.retrieve(link, filename='some_program.f') url.close() output = subprocess.check_call('gfortran some_program.f',shell=True) print(output) # output flag of zero means successful p1 = subprocess.Popen('./a.out',stdout=subprocess.PIPE) print(p1.stdout.readline()) import signal p1.send_signal(signal.SIGSTOP) # temporarily halt the executing of a program p1.send_signal(signal.SIGCONT) # continue the program p1.send_signal(signal.SIGKILL) # kill the program os.remove('a.out') from glob import glob sorted(glob('[hn]*.txt'))