0

I have a directory that when accessed through the terminal, I run the command 'make' then 'make install' which subsequently builds a dictionary file. I want to automate this process, which will kick off when the user selects a button on the interface.

Using PHP in my web app I want to navigate to the directory which I have done so here:

chdir('../DictionaryFolder');

Then, I thought this PHP command would run the make and make install:

exec(make);
exec(make install);

But this does nothing.

Any help will be much appreciated!

2 Answers 2

1

You need to write the command like the following,

<?php 
     $output = shell_exec('make;make install;');
     echo "<pre>$output</pre>";
?>

Shell exec will do the trick by calling $output via pre tag.

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

2 Comments

The output displayed (for some reason, only the first 4 lines) is as expected, but the dictionary file which is normally built when the command is run from the terminal, does not appear
Sorry, I realised the permissions on the folder I was trying to access were read only, after changing to read & write it worked!
1

Exec() try to execute PHP like eval() in JS, shel_exec execute commande like you with CLI

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.