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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:14:41+00:00 2026-06-07T13:14:41+00:00

I want to log all calls to subprocess.Popen, so that I can create a

  • 0

I want to log all calls to subprocess.Popen, so that I can create a batch/shell file that is equivalent.

How does python turn the list of arguments into a command?

Is it equivalent to ' '.join([args])?

For example:

args=['ls', '-A']
subprocess.Popen(args)
# ...

I want to get an equivalent file to all the calls:

ls -A
  • 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-07T13:14:44+00:00Added an answer on June 7, 2026 at 1:14 pm

    No, it’s not equivalent to that (since some of the arguments might have spaces or other shell meta-characters in them). In fact, unless you use shell=True, Python doesn’t need to combine all the arguments into one string at all. It uses an exec*()-like call (see man execve) and passes the arguments in an array.

    If you just want to output enough information to recreate the argument list later, then you might just want to output repr(args).

    Since your goal is to make an equivalent batch/shell file, you probably need to take special steps to quote arguments so that any special metacharacters inside them won’t affect how the shell splits up the arguments. One way to do that is to pass each argument through a function like the one I put up at https://gist.github.com/790722 (although it doesn’t know how to do safe quoting for batch files).

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

Sidebar

Related Questions

log4perl has a threshold option in the configuration file that will log all calls
I want to log/write all Javascript errors to a text file whenever an error
I'm writing a python script that uses subprocess.Popen to execute two programs (from compiled
I want to log all calls to all class methods with a specific attribute.
I want to log all toasts events in android ics (4.0.3), but I was
I want to log all clicks in a MainMenu control I am using in
I am writing a server in PHP where I want to log all database
I want to be able to log all JMX data accessible via jconsole. Is
I want to log the URLs of all the popup attempts in my FireFox
I want all my applications log to be centralized (ideally in near real-time). We

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.