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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:47:21+00:00 2026-06-03T11:47:21+00:00

I am running mongoimport command using python commands module as status = utilities.execute(mongoimport) in

  • 0

I am running mongoimport command using python commands module as

status = utilities.execute(mongoimport)

in utilities.py

def execute(command):
    if not command:
        return (-1, 'command can not be empty or null')
    return commands.getstatusoutput(command)  

When I run this, I see error as

sh: Syntax error: ";" unexpected 

I see that documentation says :

commands.getstatusoutput(cmd)
Execute the string cmd in a shell with os.popen() and return a 2-tuple (status, output). cmd is actually run as { cmd ; } 2>&1, so that the returned output will contain output or error messages  

How can I fix this to be able to run this command?

  • 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-03T11:47:23+00:00Added an answer on June 3, 2026 at 11:47 am

    Use the subprocess module

    from subprocess import check_output
    output = check_output(["ls", "-l"])
    

    This will raise an error if the command fails – no need to check for empty string. If you are really sure that you want to pass stuff through the shell then call like this

    output = check_output("ls -l", shell=True)
    

    Just note that passing stuff through the shell is an excellent vector for security problems.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Running Nh 3.2 using SQLite throws the following exception: ---> NHibernate.HibernateException: Could not create
-- Running within ASP.NET MVC alongside jQuery -- I'm using jQuery to render a
Running Mac OS X 10.5.8, with PHP 5.2.11 Pre-installed. Using Coda 1.6.10. I'm writing
Running the command generates new rails projects: $ rails generate controller home index The
Running the following code, I get a StackOverflowError at the getPackage() line. How can
Running this in python will result in a WindowsError stating it cannot find the
Running Rails 3.1.3... I'll use a simple example of nested associations (not sure if
Running IIS 6 with a main website using .net 4. I have many sub
running UNIX through putty, and using vi and gcc. I am attempting to read
Running Ubuntu 10.04 on Linode, RVM, Rails 3, Apache with Passenger module, carrierwave and

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.