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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:27:06+00:00 2026-05-23T15:27:06+00:00

I am wondering is this safe way to put ps aux into array and

  • 0

I am wondering is this safe way to put ps aux into array and then display on the web? Or what could be done to improve it?

Example:

<table width="900px" border="1">
    <tr> 
        <td> PID </td>
        <td> CPU </td>
        <td> Mem </td>
        <td> Start </td>
        <td> Command</td>
    </tr>
    <?php
    exec("ps aux | grep -v grep | grep  process.php", $psOutput);
    if (count($psOutput) > 0) {
        foreach ($psOutput as $ps) {
            $ps = preg_split('/ +/', $ps);
            $pid = $ps[1];
            $cpu = $ps[2];
            $mem = $ps[3];
            $time = $ps[8];
            $command = $ps[10] . " " . $ps[11];
            echo "<tr>";
              echo "<td>" . $pid . "</td>";
              echo "<td>" . $cpu . "</td>";
              echo "<td>" . $mem . "</td>";
              echo "<td>" . $time . "</td>";
              echo "<td>" . $command . "</td>";
            echo "</tr>";
        }
    }
    ?>
</table>
  • 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-23T15:27:06+00:00Added an answer on May 23, 2026 at 3:27 pm

    I am wondering is this safe way to put ps aux into array and then display on the web? Or what could be done to improve it?

    Nothing as far as I can tell. If this is the actual code and the command isn’t created from user input, there is absolutely nothing wrong with this code, apart from the fact that <table width="900px"> is generally controlled by CSS, not HTML. But that’s all the critique I can think of.

    EDIT: Quentin makes a very valid point in that you should use htmlspecialchars before displaying in HTML.

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

Sidebar

Related Questions

So I'm wondering in Java is this safe? HttpClient client = new DefaultHttpClient(); HttpResponse
I was wondering if it is safe to do this... delete p_pointer; p_pointer =
I was wondering if something like this, is safe in Zend: $db = Zend_Registry::get('db');
I was wondering if something like this is safe... // Iterating through a <list>
I'm wondering if it's safe to cast a double (*)(double) to double(*)(...) , this
I've been wondering this for a while but since it hasn't come up much
I've been wondering this for some time. As the title say, which is faster,
Wondering if this is possible. We have an 3rd Party library that contains identification
Just wondering is this kind of code recommended to increase performance? void functionCalledLotsofTimes() {
I'm wondering if this is a good design. I have a number of tables

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.