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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:49:44+00:00 2026-05-23T00:49:44+00:00

If I put this in my script: $output = array(); exec("/var/www", $output); var_dump($output); I

  • 0

If I put this in my script:

$output = array();
exec("/var/www", $output);
var_dump($output);

I get an array of all the files in that folder.

However when I do this:

$output = array();
exec("../node_modules/less/bin/lessc ./default.less", $output);
var_dump($output);

The output I get is

array(0) {}

If I run the same command in the command line (from the same directory my php script is in) it works fine.

I also tried absolute paths:

/var/www/node_modules/less/bin/lessc /var/www/nodeless/default.less

Here is the permissions for these files:

drwxr-xr-x 2 ftpuser ftpuser 4096 2011-06-06 16:43 nodeless

drwxr-xr-x 4 ftpuser www-data 4096 2011-06-06 15:44 node_modules

Any ideas why I can’t do it from PHP?

  • 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-23T00:49:45+00:00Added an answer on May 23, 2026 at 12:49 am

    I really owe finding the solution to my problem to the help from Radu and Tomalak Geret’kal. However as Radu’s answer currently stands, it does not describe what fixed my issue. So I will explain it here.

    I tried to SSH into the server using the same user as PHP (www-data) and execute the same command. I was given this error:

    /usr/bin/env: node: No such file or directory

    As it turns out when I first installed node.js, the instructions I followed told me to add the path to my $PATH environment variable. However that was a different user than www-data, so the path to node was not in my $PATH any longer when using the www-data user.

    I am not expert in this area but I assumed that was likely the problem. So I started over following the installation instructions for node.js, only this time as the www-data user.

    Afterwards I could then execute the command on the command line as www-data. So I tried my PHP script again. It now worked as well.

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

Sidebar

Related Questions

In my Apache webserver I put this: <Directory /var/www/MYDOMAIN.com/htdocs> SetHandler mod_python PythonHandler mod_python.publisher PythonDebug
If you have a string of 1,2,3,1,5,7 you can put this in an array
I have a array which contains values like this See below for script sample
I'm writing a simple php/mysql script that gets all ads I have in my
I have this ajax_update script that updates file.php every 60 seconds.. Now file.php outputs
I am trying to cache everything that is output by layout script and controller's
I put this at the top, using sudo vi /etc/profile: PYTHONPATH=/home/myuser:/home/myotheruser When I use
If I put this tag in my HTML: <img src=http://server/imageHandler.php?image=someImage.jpg /> instead of <img
Edit: I put this snippet of code in jsbin: http://jsbin.com/eneru I am trying to
It's hard to put this into the title, so let me explain. I have

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.