[Tutor] Using command line tool with python script

bob gailer bgailer at gmail.com
Mon Oct 5 16:32:14 CEST 2009

Oleg Oltar wrote:
> Hi!
> I want to try to use a command line script with my python application. 
> The task is the following, my database stores some initial data for 
> the script and
> I need to execute a command line application in a following way:
> $ application -parameter1 -file1
> where file 1 is a file which contains my initial data, and parameter1 
> is unrelated parameter
> the workflow as I see it know is following
> initial_data = get_initial_data_from_db()
> file = open('temp.txt', 'w+')
> file.write(initial_data)
> file.save()
> os.popen4("application -parameter1 -file temp.txt")
> I wonder if that possible to execute this script (called application) 
> without writing the file with initial data to the hard disk?

Take a look at os.system()

Bob Gailer
Chapel Hill NC

More information about the Tutor mailing list