Problem running a script in php?

Asked

Viewed 393 times

0

created a script to run a program automatically, it is correct because in the command line in Ubuntu it runs through the command:

/var/www/html/trabalhoTCC/view/needle.sh /var/www/html/trabalhoTCC/emboss/aaindexextract/alvos.txt  /var/www/html/trabalhoTCC/emboss/aaindexextract/modelos.txt

where Needle.sh is my script that takes as parameter the files al.txt and mod.txt.

In the Ubuntu terminal I can run this command and have its output file, but by running this command in php :

shell_exec('/var/www/html/trabalhoTCC/view/needle.sh /var/www/html/trabalhoTCC/emboss/aaindexextract/alvos.txt /var/www/html/trabalhoTCC/emboss/aaindexextract/modelos.txt');

I don’t get the exit, someone knows what can be?

  • Look at this part that you put it this way in the script ? because at the end of the command has a simple QUOTE, remove it

  • Another thing, try to put everything in one line

  • no quotes, I put wrong here. .

  • Right, now in the script puts everything in one line: shell_exec('/var/www/html/job/view/Needle.sh /var/www/html/job/view/Emboss/Needle/al.txt /var/www/html/job/view/Emboss/Needle/mod.txt');

  • I tidied here had put wrong too, this way is and I get no way out.

  • All right, check the permission to run the Needle.sh file

Show 1 more comment

1 answer

2


Checks whether the functions exec() and shell_exec() are enabled in PHP.

Solution

The file / directory ( folder ) was not allowed enough, so the file could be run.

Permission was given using the command chmod.

  • functions are enabled because I ran the chmod command with shell_exec and it worked.

  • You can redirect shell errors with 2>&1 at the end of your script to know what is going wrong.

  • this me returning this error Gap Opening penalty [10.0]: Gap Extension penalty [0.5]: Output Alignment [hba_human.Needle]: Warning: Failed to open output file 'hba_human.Needle' error:13 'Permission denied' Error: Unable to open Alignment file 'hba_human.Needle' Output Alignment [hba_human.Needle]: , which has no permission to open the output file, but in Ubuntu when running the same script it works, something from php?

  • Give execution permission to the file so it can run as chmod 777 /var/www/html/trabalhoTCC/view/needle.sh. Attention: this is a drastic example that gives all permissions to everyone. Take a look at the documentation of POCKETS OVER GAPS

  • discovered the error the view folder that I put the script to test was not allowed to output so the output could not be saved in that folder, thank you very much.

  • @user86792 updates the answer according to the solution of the problem

  • @Wmsouza I would think it fair that you write the answer and that your answer is marked as correct. I just saw that you gave the tip to check the permissions 14 minutes before me. I just put an answer here because I couldn’t comment. (Reputation below 50 points)

  • No problem, we’re here to help, you can edit.

Show 3 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.