2

I have this:

exec('lsblk -no "UUID" 2>&1', $result);
print_r($result);

in CLI mode, everything is fine, the output is:

Array
(
    [0] =>
    [1] =>
    [2] => d5b31fcc-ba84-47bc-ab1e-7f71178c791f
    [3] =>
    [4] => Dj0hJ3-c9C4-B1px-HIYW-DGwi-v9I9-eppfgL
    [5] => e266aff1-e6a7-444a-b9b3-2da2f9b71202
    [6] => 3fc422ac-0cde-4b54-aab1-cac10d3d5f0b
    [7] =>
)

But from http, the output is:

Array
(
    [0] => 
    [1] => 
    [2] => 
    [3] => 
    [4] => 
    [5] => 
    [6] => 
    [7] => 
)

Is this a bug, or a charset problem?

5
  • Try to do: var_dump($result); and look into the source code if you see anything in the browser? Commented May 4, 2015 at 13:06
  • 3
    it's likely to be a permission issue, where when you're logged into the console you have access to that binary, and the process of your webserver does not. Commented May 4, 2015 at 13:07
  • @Rizier123 still empty strings... [0]=> string(0) ""; @Augwa I don't think it's about permissions, because I have the same size of the array both cases, just without values Commented May 4, 2015 at 13:08
  • try changing lsblk -no "UUID"; 2>&1 also perhaps you have permissions to view the uuid with your user at the cli and the webserver does not so it just returns empty strings. Commented May 4, 2015 at 13:25
  • Thank you @Augwa you were right, it's about permissions about the uuid! Commented May 4, 2015 at 13:29

1 Answer 1

1

The issue is that when you are logged in via the CLI the user which we'll call root. However when you are accessing through your browser, which goes through your webserver, it's logged in with a different user which we'll apache.

root has access to the UUID, apache does not.

The actual users on your specific machine may vary.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.