how to execute win cmd from php code? -
i have x.exe in path: c:\inetpub\wwwroot\webclient\db\nucleotide , want execute command: blastdbcmd -db nr -entry -outfmt "%g %t".
in windows command line do:
cd c:\inetpub\wwwroot\webclient\db\nucleotide blastdbcmd -db nr -entry -outfmt "%g %t" how can php code. know exec($cmd) or shell_exec($cmd) but, how type above 2 statement in $cmd?
edit1: how save output of command in text file? try 3 statement:
chdir("c:\\inetpub\\wwwroot\\webclient\\db\\nucleotide"); $cmd = "blastdbcmd.exe -db nr -entry -outfmt "%g %t" -out $text_files_path/newseq_$olddatabasefile$newdatabasefile.txt"; exec($cmd); ,,
exec("c:\inetpub\wwwroot\webclient\db\nucleotide\blastdbcmd.exe -db nr -entry -outfmt "%g %t" -out $text_files_path/newseq_$olddatabasefile$newdatabasefile.txt"); ,,
exec("cd c:\inetpub\wwwroot\webclient\db\nucleotide && blastdbcmd.exe -db nr -entry -outfmt \"%g %t\" -out $text_files_path/newseq_$olddatabasefile$newdatabasefile.txt"); but, newseq_$olddatabasefile$newdatabasefile.txt not generated. seems command not executed!
what can do?
thanks.
three options:
you can prepend .exe path:
exec("c:\inetpub\wwwroot\webclient\db\nucleotide\blastdbcmd.exe -db nr -entry -outfmt \"%g %t\""); // don't forget escape quotes. if .exe reason requires run directory, change chdir() before execute it.
chdir("c:\inetpub\wwwroot\webclient\db\nucleotide"); exec("blastdbcmd.exe -db nr -entry -outfmt \"%g %t\""); alternatively can change directory , run command in single line:
exec("cd c:\inetpub\wwwroot\webclient\db\nucleotide && blastdbcmd.exe -db nr -entry -outfmt \"%g %t\"");
Comments
Post a Comment