3

Here is my php code

$command = "C:\Program Files\ClustalW2>clustalw2 -INFILE=seq.txt -TYPE=Protein -OUTFILE=res.aln";
exec($command);

When i run the command using the cmd, it generates the desired file. However when i try passing the same command via my php code it generates no result. How do i fix this problem?

13
  • try using back tick operator ` try this php.net/manual/en/language.operators.execution.php Commented Mar 19, 2012 at 6:12
  • Probably you don't have permission to run this command from a PHP Script...... Commented Mar 19, 2012 at 6:12
  • @Mian_Khurram_Ijaz: i am new to php, so wud like to knw wats the differnce between the two? And wat may the problems in using exec()?? Commented Mar 19, 2012 at 6:15
  • @SayemAhmed: what do u mean by no permission to run this command?? Commented Mar 19, 2012 at 6:16
  • 1
    @Nikita: You want to run a command on the cmd. Doing so required user privileges from the operating systems. Are you sure you can run this command from your web app in the host machine? Does the web app have sufficient privileges granted to it? Commented Mar 19, 2012 at 6:19

1 Answer 1

2

Probably it's because of the > symbol before executable's filename? Also, try with single quotes:

$command = 'C:\Program Files\ClustalW2\clustalw2 -INFILE=seq.txt -TYPE=Protein -OUTFILE=res.aln';
exec($command, $output, $retval);
var_dump($output);
var_dump($retval);
Sign up to request clarification or add additional context in comments.

2 Comments

I tried what u have suggested but it still doesnt work. Also the single quotes make no difference..
@Nikita Do you see any warnings/errors? Try running modified version of the code snippet

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.