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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:28:03+00:00 2026-05-11T03:28:03+00:00

I have a PHP script which executes a shell command: $handle = popen(‘python last’,

  • 0

I have a PHP script which executes a shell command:

$handle = popen('python last', 'r'); $read = fread($handle, 4096); print_r($read); pclose($handle); 

I echo the output of the shell output. When I run this in the command I get something like this:

[root@localhost tester]# python last [last] ZVZX-W3vo9I: Downloading video webpage [last] ZVZX-W3vo9I: Extracting video information [last] ZVZX-W3vo9I: URL: x [download] Destination: here.flv [download]   0.0% of 10.09M at     ---b/s ETA --:-- [download]   0.0% of 10.09M at   22.24k/s ETA 07:44 [download]   0.0% of 10.09M at   66.52k/s ETA 02:35 [download]   0.1% of 10.09M at  154.49k/s ETA 01:06 [download]   0.1% of 10.09M at  162.45k/s ETA 01:03 

However, when I run that same command from PHP I get this output:

[last] ZVZX-W3vo9I: Downloading video webpage [last] ZVZX-W3vo9I: Extracting video information [last] ZVZX-W3vo9I: URL: x [download] Destination: here.flv 

As you can see the bottom bit is missing which is the bit I need!! The problem before was that the percentages were being updated on the same line but now I have changed my Python script so that it creates a new line. But this made difference! 🙁

This question is related to this one.

Thank you for any help.

Update

Needed to redirect output ‘2>&1’. Arul got lucky 😛 since I missed the deadline to pick the one true answer which belonged to Pax!

  • 1 1 Answer
  • 1 View
  • 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. 2026-05-11T03:28:04+00:00Added an answer on May 11, 2026 at 3:28 am

    You read only the first 4,096 bytes from the pipe, you’ll need to place the fread/print_r in a loop and check for the end-of-file using the feof function.

    $handle = popen('python last', 'r');  while(!feof($handle)) {     print_r(fread($handle, 4096)); }   pclose($handle); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 102k
  • Answers 102k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you need efficient serialization, and don't care if its… May 11, 2026 at 8:14 pm
  • Editorial Team
    Editorial Team added an answer Two comments without the benefit of any actual measurement to… May 11, 2026 at 8:14 pm
  • Editorial Team
    Editorial Team added an answer The WPF Unleashed book as Nicholas mentioned is indeed excellent,… May 11, 2026 at 8:14 pm

Related Questions

I have a PHP script which executes a shell command: $handle = popen('python last',
I want to deploy my site on my web hosting package by doing a
I am working on a website that passes all PHP scripts through a single
I have a php script which is executed over a URL. (e.g. www.something.com/myscript?param=xy) When
I have a php script which accesses a MSSQL2005 database, reads some data from

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.