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 6620539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:06:50+00:00 2026-05-25T21:06:50+00:00

all. I am trying to use python 2.7.1 to run batch files based on

  • 0

all. I am trying to use python 2.7.1 to run batch files based on what a user enters at the input prompt. The problem I’m having is the batch files do not run. I have been able to get a specific batch file to run from python if it is called from main() but cannot get python to select the file based on the input value. My code is:

from subprocess import Popen


def results():
    Popen("results.txt")
    selection()

def buildinga():
    Popen("5463.bat")
    results()

def base():
    Popen("base.bat")
    results()

def selection():
    print "This tool will check the device status for the specified building."
    print "Type 'exit' to quit the program."
    selection.c = input("Please enter the device number: ")


    if selection.c == "001":
        base()

    if selection.c == "5463":
        buildinga()

    if selection.c == "exit":
        exit()



def main():
    selection()


main()

The way I can run a single batch file is:

from subprocess import Popen

def batchwriter():
    Popen("make.bat")

def main():
    batchwriter()

main()

This way does not allow me to select which batch file to run, only the one specified. Any help would be much appreciated.

I tried to post this in comments but could not. raw_input is working. The batch file is being run and then the results file displays, however, errors are displayed, as well. The errors don’t seem to affect functionality because the results are correct. I am getting the following output:

This tool will check the device status for the specified building.
Type 'exit' to quit the program.
Please enter the device number: 5463
Traceback (most recent call last):
  File "M:\cstat\ct.py", line 37, in <module>
    main()
  File "M:\cstat\ct.py", line 34, in main
    selection()
  File "M:\cstat\ct.py", line 26, in selection
    buildinga()
  File "M:\cstat\ct.py", line 10, in buildinga
    results()
  File "M:\cstat\ct.py", line 5, in results
    Popen("results.txt")
  File "C:\Utilities\Python\lib\subprocess.py", line 672, in __init__
    errread, errwrite)
  File "C:\Utilities\Python\lib\subprocess.py", line 882, in _execute_child
    startupinfo)
WindowsError: [Error 2] The system cannot find the file specified

M:\cstat>[ 12:11:36.63] 5463 is ONLINE
  • 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-25T21:06:51+00:00Added an answer on May 25, 2026 at 9:06 pm

    Use raw_input istead of input. input converts numeric input to from string to integer.

    >>> input()
    001
    1
    >>> raw_input()
    001
    '001'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to run Python scripts using Xcode's User Scripts menu. The issue I'm
I'm trying to use XPath to find all elements that have an element in
I'm trying to use VDMEnumProcessWOW to find all 16 bit host processes on Vista.
I'm trying to use JQuery to select all of the TD 's in a
I'm trying to use the PowerShell Add-Member cmd on all the items in an
I'm trying to use the getElementsByTagName(a) method to get all the elements under a
I'm trying to use Linq to loop through all fonts in the %windir%\Fonts folder
I'm trying to use strace to monitor all file accesses by g++ but it
I am trying to use same validation function for all my controls. But I
I am trying to use Linq2Sql to return all rows that contain values from

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.