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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:13:00+00:00 2026-06-05T23:13:00+00:00

I have a PHP file with shell commands running through a screen, the commands

  • 0

I have a PHP file with shell commands running through a screen, the commands run fine but I was wondering if there was a way to get this to output to PHP without writing to another file and reading it on PHP’s end.

PHP – trace() is just a fancy print_r()

$cmd = 'ls -h /';
trace(shell_exec('screen -S output -p 0 -X stuff "`echo '.$cmd.'\'\r\n\'`"'));

Web output

NULL

Screen output

www-data@:/home/ubuntu$ ls -h /
bin   build  etc   initrd.img      lib         media  opt   root  selinux  sys  usr  vmlinuz
boot  dev    home  initrd.img.old  lost+found  mnt    proc  sbin  srv      tmp  var  vmlinuz.old

Any suggestions?

–Edit–

Certain commands aren’t outputting directly, one of the reasons I’m using screen

PHP

$cmd = 's3ls';
trace(shell_exec('screen -S output -p 0 -X stuff "`echo '.$cmd.'\'\r\n\'`"'));
trace(shell_exec($cmd));

Web output

trace:NULL
trace:NULL

Screen

www-data@:/home/ubuntu$ s3ls
+---------------+--------------------------+
|     Name      |       CreationDate       |
+---------------+--------------------------+
| bucket        | 2012-05-31T13:08:51.000Z |
| bucket        | 2012-01-17T16:51:58.000Z |
| bucket        | 2012-03-31T11:19:54.000Z |
+---------------+--------------------------+
  • 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-05T23:13:01+00:00Added an answer on June 5, 2026 at 11:13 pm

    void passthru ( string $command [, int &$return_var ] )

    The passthru() function is similar to the exec() function in that it
    executes a command. This function should be used in place of exec() or
    system() when the output from the Unix command is binary data which
    needs to be passed directly back to the browser. A common use for this
    is to execute something like the pbmplus utilities that can output an
    image stream directly. By setting the Content-type to image/gif and
    then calling a pbmplus program to output a gif, you can create PHP
    scripts that output images directly.

    Though apparently it may be a bit flaky.

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

Sidebar

Related Questions

I have a PHP file with one simple echo function: echo 'アクセスは撥ねりません。'; but when
I have a php file at my site, and I connect to db, get
I need to execute a php file with parameters through shell. here is how
Is there a way to run the following script via PHP http://www.magentoadvisor.com/magento-backup/tutorial-magento-backup-scripts-part-2/ I have
I have a web application which runs FontForge shell commands using shell_exec() in PHP.
If I run my PHP file from the shell, then the tar command extracts
I have seen a PHP code that uses shell commands to determinate if this
I have a PHP file which will return something like <div id=title>Add Us On
I have a PHP file that contains a lot of if and else statements
I have a php file somejson.php that echos a json encoded array {jsonone:first json,jsontwo:second

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.