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

  • Home
  • SEARCH
  • 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 8234307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:25:49+00:00 2026-06-07T18:25:49+00:00

I am attempting to run a command in terminal through a Python script. The

  • 0

I am attempting to run a command in terminal through a Python script. The command, which only takes three arguments, works perfectly when performed in terminal. Here is what is entered in the command line:

gpmetis inputfile numberOfSections

Wherever the inputfile is from, say the Desktop, the outputfile is dumped in the same location after gpmetis is executed (it is named inputfile.part.numberOfSections). gpmetis only works in terminal, but for condensing purposes, I want to use it during the middle of the Python script to save time. (I would previously just shuffle around files to and from terminal and Python)

But this is where I run into problems… this question and this forum gave helpful hints on how to execute terminal within Python, but I’m still not receiving the outputfile when I run the python code. It’s like the output is suppressed or the way I call terminal is faulty.

I’m currently calling terminal like:

def Terminal(inputfile, NumParts): 
    os.system("gpmetis inputfile NumParts")

    outputfile = "inputfile.part." + NumParts
    return outputfile

And I don’t get an error from this, but I don’t receive any output file either. What am I missing here and if you know could you explain it? I’m trying to learn Python, so describing what I’m screwing up would be much appreciated.

os has been imported. There may be a fault with how I am “returning” the outputfile in my script, but I also do not see an outputfile on my desktop, which is the first problem to be dealt with (one step at a time!)

NOTE: I found documentation that is related, but will it help me? I’m having trouble understanding it..

  • 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-06-07T18:25:51+00:00Added an answer on June 7, 2026 at 6:25 pm

    First, you might check the return value of os.system. A non-zero return value usually indicates that an error has occurred.

    It looks like you are trying to use the parameters in your command. In that case it should look like:

    def Terminal(inputfile, NumParts): 
        command = 'gpmetis ' + inputfile + ' ' + str(NumParts)
        os.system(command)
    
        outputfile = intputfile + '.part.' + str(NumParts)
        return outputfile
    

    Lastly, based on this answer, it looks like you may be better off using the subprocess module. You can then execute the same command like this:

    import subprocess
    subprocess.call(['gpmetis', inputfile, str(NumParts)])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to run the following command in KornShell (ksh): set -A INDEXES
I'm attempting to run the following command in PHP (on Ubuntu): <?php if (exec(/home/johnboy/ffmpeg/ffmpeg
I am attempting to run some unit tests in python from what I believe
I am attempting to run a Groovy script in Eclipse but Eclipse is seemingly
Attempting to run a MIB based SNMP script and I running into an issue.
I am attempting to run VLCJ test jar from command line. VLCJ requires two
I'm attempting to run a SSH command from a remote server with PHP's ssh2
I am attempting to run the following PowerShell command against my Exchange 2010 SP1
I have a perfectly functioning perl script (written in bash terminal on debian linux)
In attempting to run ./manage.py runserver or shell or any other command for that

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.