Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 387937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:43:16+00:00 2026-05-12T15:43:16+00:00

I want to try to use a command line script with my python application.

  • 0

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

Here file1 is a file which contains my initial data, and parameter1 is an unrelated parameter.

The workflow as I see it now is the 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 it’s possible to execute this script (called application) without writing the file with initial data to the hard disk? E.g. is there a way send the files contents to the command directly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T15:43:16+00:00Added an answer on May 12, 2026 at 3:43 pm

    You can use the subprocess modul

    something like that:

    import subprocess
    bufsize =1024
    initial_data = get_initial_data_from_db()
    p = subprocess.Popen("application -parameter1", shell=True, bufsize=bufsize,
              stdin=subprocess.PIPE,   close_fds=True)
    
    p.stdin.write(initial_data)
    print p.communicate()
    

    ! if your application can read from stdin

    Testing with Python as Application (in Eclipse) / after remark from Oleg Tarasenko :

    import subprocess
    
    initial_data = """
    import sys
    print sys.path
    """
    
    for test in [1,2,3] :
        p = subprocess.Popen("C:/python26/python", shell=True, bufsize=512,
              stdin=subprocess.PIPE,  stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
    
        p.stdin.write(initial_data)
        print p.communicate()
    

    Output:

    ("['', 'C:\\\\dev\\\\ide\\\\eclipse\\\\plugins\\\\org.python.pydev_1.5.0.1251989166\\\\PySrc\\\\pydev_sitecustomize', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\src', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\libs', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\jars\\\\jacob.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\jars\\\\jiffie.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\jars\\\\jaxen-1.1.1.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\jars\\\\swt.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\jars\\\\mysql-connector-java-3.0.17-ga-bin.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\nlibs\\\\qpslib.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\nlibs\\\\ifxjdbc.jar', 'C:\\\\server\\\\jboss\\\\client\\\\jbossall-client.jar', 'C:\\\\usr\\\\local\\\\machine', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\event\\\\src\\\\build\\\\components\\\\jobcontrol\\\\config', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\event\\\\src\\\\build\\\\components\\\\jobcontrol', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\event\\\\src', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\oknos\\\\tickcardimp\\\\bin', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\common\\\\jar\\\\shared.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\src', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\libs', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\jars\\\\jacob.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\jars\\\\jiffie.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\jars\\\\jaxen-1.1.1.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\jars\\\\swt.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\jars\\\\mysql-connector-java-3.0.17-ga-bin.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\nlibs\\\\qpslib.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\nlibs\\\\ifxjdbc.jar', 'C:\\\\server\\\\jboss\\\\client\\\\jbossall-client.jar', 'C:\\\\usr\\\\local\\\\machine', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\event\\\\src\\\\build\\\\components\\\\jobcontrol\\\\config', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\event\\\\src\\\\build\\\\components\\\\jobcontrol', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\event\\\\src', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\oknos\\\\tickcardimp\\\\bin', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\common\\\\jar\\\\shared.jar', 'C:\\\\jython\\\\jython2.5.0\\\\Lib', 'C:\\\\jython\\\\jython2.5.0\\\\Lib\\\\site-packages', 'C:\\\\dev\\\\java\\\\jdk1.5.0_17\\\\jre\\\\lib\\\\rt.jar', 'C:\\\\dev\\\\java\\\\jdk1.5.0_17\\\\jre\\\\lib\\\\jsse.jar', 'C:\\\\dev\\\\java\\\\jdk1.5.0_17\\\\jre\\\\lib\\\\jce.jar', 'C:\\\\dev\\\\java\\\\jdk1.5.0_17\\\\jre\\\\lib\\\\charsets.jar', 'C:\\\\dev\\\\java\\\\jdk1.5.0_17\\\\jre\\\\lib\\\\ext\\\\dnsns.jar', 'C:\\\\dev\\\\java\\\\jdk1.5.0_17\\\\jre\\\\lib\\\\ext\\\\localedata.jar', 'C:\\\\dev\\\\java\\\\jdk1.5.0_17\\\\jre\\\\lib\\\\ext\\\\sunjce_provider.jar', 'C:\\\\dev\\\\java\\\\jdk1.5.0_17\\\\jre\\\\lib\\\\ext\\\\sunpkcs11.jar', 'C:\\\\WINDOWS\\\\system32\\\\python26.zip', 'C:\\\\python26\\\\DLLs', 'C:\\\\python26\\\\lib', 'C:\\\\python26\\\\lib\\\\plat-win', 'C:\\\\python26\\\\lib\\\\lib-tk', 'C:\\\\python26']\r\n", "'import site' failed; use -v for traceback\r\n")
    ("['', 'C:\\\\dev\\\\ide\\\\eclipse\\\\plugins\\\\org.python.pydev_1.5.0.1251989166\\\\PySrc\\\\pydev_sitecustomize', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\src', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\libs', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\jars\\\\jacob.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\jars\\\\jiffie.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\jars\\\\jaxen-1.1.1.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\jars\\\\swt.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\jars\\\\mysql-connector-java-3.0.17-ga-bin.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\nlibs\\\\qpslib.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\nlibs\\\\ifxjdbc.jar', 'C:\\\\server\\\\jboss\\\\client\\\\jbossall-client.jar', 'C:\\\\usr\\\\local\\\\machine', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\event\\\\src\\\\build\\\\components\\\\jobcontrol\\\\config', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\event\\\\src\\\\build\\\\components\\\\jobcontrol', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\event\\\\src', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\oknos\\\\tickcardimp\\\\bin', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\common\\\\jar\\\\shared.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\src', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\libs', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\jars\\\\jacob.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\jars\\\\jiffie.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\jars\\\\jaxen-1.1.1.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\jars\\\\swt.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\jars\\\\mysql-connector-java-3.0.17-ga-bin.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\nlibs\\\\qpslib.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\nlibs\\\\ifxjdbc.jar', 'C:\\\\server\\\\jboss\\\\client\\\\jbossall-client.jar', 'C:\\\\usr\\\\local\\\\machine', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\event\\\\src\\\\build\\\\components\\\\jobcontrol\\\\config', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\event\\\\src\\\\build\\\\components\\\\jobcontrol', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\event\\\\src', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\oknos\\\\tickcardimp\\\\bin', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\common\\\\jar\\\\shared.jar', 'C:\\\\jython\\\\jython2.5.0\\\\Lib', 'C:\\\\jython\\\\jython2.5.0\\\\Lib\\\\site-packages', 'C:\\\\dev\\\\java\\\\jdk1.5.0_17\\\\jre\\\\lib\\\\rt.jar', 'C:\\\\dev\\\\java\\\\jdk1.5.0_17\\\\jre\\\\lib\\\\jsse.jar', 'C:\\\\dev\\\\java\\\\jdk1.5.0_17\\\\jre\\\\lib\\\\jce.jar', 'C:\\\\dev\\\\java\\\\jdk1.5.0_17\\\\jre\\\\lib\\\\charsets.jar', 'C:\\\\dev\\\\java\\\\jdk1.5.0_17\\\\jre\\\\lib\\\\ext\\\\dnsns.jar', 'C:\\\\dev\\\\java\\\\jdk1.5.0_17\\\\jre\\\\lib\\\\ext\\\\localedata.jar', 'C:\\\\dev\\\\java\\\\jdk1.5.0_17\\\\jre\\\\lib\\\\ext\\\\sunjce_provider.jar', 'C:\\\\dev\\\\java\\\\jdk1.5.0_17\\\\jre\\\\lib\\\\ext\\\\sunpkcs11.jar', 'C:\\\\WINDOWS\\\\system32\\\\python26.zip', 'C:\\\\python26\\\\DLLs', 'C:\\\\python26\\\\lib', 'C:\\\\python26\\\\lib\\\\plat-win', 'C:\\\\python26\\\\lib\\\\lib-tk', 'C:\\\\python26']\r\n", "'import site' failed; use -v for traceback\r\n")
    ("['', 'C:\\\\dev\\\\ide\\\\eclipse\\\\plugins\\\\org.python.pydev_1.5.0.1251989166\\\\PySrc\\\\pydev_sitecustomize', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\src', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\libs', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\jars\\\\jacob.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\jars\\\\jiffie.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\jars\\\\jaxen-1.1.1.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\jars\\\\swt.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\jars\\\\mysql-connector-java-3.0.17-ga-bin.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\nlibs\\\\qpslib.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\nlibs\\\\ifxjdbc.jar', 'C:\\\\server\\\\jboss\\\\client\\\\jbossall-client.jar', 'C:\\\\usr\\\\local\\\\machine', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\event\\\\src\\\\build\\\\components\\\\jobcontrol\\\\config', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\event\\\\src\\\\build\\\\components\\\\jobcontrol', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\event\\\\src', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\oknos\\\\tickcardimp\\\\bin', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\common\\\\jar\\\\shared.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\src', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\libs', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\jars\\\\jacob.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\jars\\\\jiffie.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\jars\\\\jaxen-1.1.1.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\jars\\\\swt.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\script_jy\\\\jars\\\\mysql-connector-java-3.0.17-ga-bin.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\nlibs\\\\qpslib.jar', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\nlibs\\\\ifxjdbc.jar', 'C:\\\\server\\\\jboss\\\\client\\\\jbossall-client.jar', 'C:\\\\usr\\\\local\\\\machine', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\event\\\\src\\\\build\\\\components\\\\jobcontrol\\\\config', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\event\\\\src\\\\build\\\\components\\\\jobcontrol', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\event\\\\src', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\oknos\\\\tickcardimp\\\\bin', 'C:\\\\dev\\\\ws\\\\central\\\\head\\\\common\\\\jar\\\\shared.jar', 'C:\\\\jython\\\\jython2.5.0\\\\Lib', 'C:\\\\jython\\\\jython2.5.0\\\\Lib\\\\site-packages', 'C:\\\\dev\\\\java\\\\jdk1.5.0_17\\\\jre\\\\lib\\\\rt.jar', 'C:\\\\dev\\\\java\\\\jdk1.5.0_17\\\\jre\\\\lib\\\\jsse.jar', 'C:\\\\dev\\\\java\\\\jdk1.5.0_17\\\\jre\\\\lib\\\\jce.jar', 'C:\\\\dev\\\\java\\\\jdk1.5.0_17\\\\jre\\\\lib\\\\charsets.jar', 'C:\\\\dev\\\\java\\\\jdk1.5.0_17\\\\jre\\\\lib\\\\ext\\\\dnsns.jar', 'C:\\\\dev\\\\java\\\\jdk1.5.0_17\\\\jre\\\\lib\\\\ext\\\\localedata.jar', 'C:\\\\dev\\\\java\\\\jdk1.5.0_17\\\\jre\\\\lib\\\\ext\\\\sunjce_provider.jar', 'C:\\\\dev\\\\java\\\\jdk1.5.0_17\\\\jre\\\\lib\\\\ext\\\\sunpkcs11.jar', 'C:\\\\WINDOWS\\\\system32\\\\python26.zip', 'C:\\\\python26\\\\DLLs', 'C:\\\\python26\\\\lib', 'C:\\\\python26\\\\lib\\\\plat-win', 'C:\\\\python26\\\\lib\\\\lib-tk', 'C:\\\\python26']\r\n", "'import site' failed; use -v for traceback\r\n")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 219k
  • Answers 219k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer strcpy(table->table[(int)ascii], morsepassed) would seem to be the way to do… May 12, 2026 at 11:46 pm
  • Editorial Team
    Editorial Team added an answer Ideally close the channel as soon as you are done… May 12, 2026 at 11:46 pm
  • Editorial Team
    Editorial Team added an answer I think I would implement the interface Comparable in the… May 12, 2026 at 11:46 pm

Related Questions

I would like to use python to make system calls to programs and time
I need to launch a server on the remote machine and retrieve the port
We have fairly large C++ application which is composed of about 60 projects in
I'm trying to write a shell script to perform actions if a users home

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.