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

The Archive Base Latest Questions

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

I have a subprocess using communicate to get the output ans saving it to

  • 0

I have a subprocess using communicate to get the output ans saving it to my database:

  p = Popen([str(pre_sync), '-avu', str(src), str(dest)], stdout=PIPE)
  syncoutput = p.communicate()
  check.log = syncoutput

It all works fine, but the output from communicate looks like this:

('sending incremental file list\n\nsent 89 bytes  received 13 bytes  204.00 bytes/sec\ntotal size is 25  speedup is 0.25\n', None)

All in a single line and with the “\n” inserted. Is there a way I can make it print each line in a new line? Thanks in advance.

  • 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-16T15:51:02+00:00Added an answer on May 16, 2026 at 3:51 pm
    syncoutput,sync_error = p.communicate()
    print(syncoutput)
    

    p.communicate() returns a 2-tuple, composed of the output from stdout and stderr. When you print the 2-tuple, you see the \n characters. When you print the string (of the new syncoutput), you will get formatted text.

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

Sidebar

Related Questions

I have been using subprocess.Popen successfully in the past, when wrapping binaries with a
I have a ruby application that executes ant as a subprocess using backtick. This
Here is what I have: process = subprocess.Popen([cmd.exe, /c appcfg.py, upload_data, --config_file=..\\bulkloader.yaml, --filename= +
I have an instance of the Popen class created through subprocess.Popen. I would like
I have written two scripts where one script calls subprocess.Popen to run a terminal
I have a function that is calling wget via subprocess.Popen. The purpose of this
I have a python based tkinter script which executes some commands using subprocess module.
So, I have been facing a problem with using subprocess for a python app
this is the idea. I'll have 'main' python script that will start (using subprocess)
I'm using Python's subprocess.Popen to perform some FTP using the binary client of the

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.