too long

I am using php file. I run cmd from my php and want to get the output of cmd in a text file.

I type:

$output = "";       
exec("cd C:\\inetpub\\wwwroot\\webclient\\db\
ucleotide && blastdbcmd.exe -entry_batch $text_files_path/NewSeqGi_$OldDatabaseFile$NewDatabaseFile.txt -db $DatabaseName -outfmt %f 2>&1",&$out, &$return_var);
foreach ($out as $line) {
$output .= $line."
";
}
file_put_contents("$text_files_path/NewSeq_$OldDatabaseFile$NewDatabaseFile.txt", $output);

Is there any way instead of using foreach to save the $out in a text file?

when I run my code, it stuck in

foreach ($out as $line) {
    $output .= $line."
";
    }

because the $out is very huge. Any idea? Thanks.

Solution

exec("cd C:\\inetpub\\wwwroot\\webclient\\db\
ucleotide && blastdbcmd.exe -entry_batch $text_files_path/NewSeqGi_$OldDatabaseFile$NewDatabaseFile.txt -db $DatabaseName -outfmt %f > $text_files_path/NewSeq_$OldDatabaseFile$NewDatabaseFile.txt 2>&1");

Thanks @DarkBee