olamur Posted March 6, 2008 Share Posted March 6, 2008 I have a question about using the command line through PHP. In my code, BarcodeGenerationTool.exe prints to file using windows printing calls. I tried this pclose(popen("BCStudio.exe $output_file", "w")); // pclose(popen("BarcodeGenerationTool.exe $output_file", "w")); and this $cmd = "@ECHO OFF BCStudio.exe $output_file BarcodeGenerationTool.exe $output_file exit"; $fh = fopen($bat_outfile,"w") or die($php_errormsg); fwrite($fh,$cmd) or die($php_errormsg); fclose($fh); exec($bat_outfile . " > NUL:") or die($php_errormsg); // appears stuck in shell // exec($bat_outfile") // this also doesn't work but when I tried running commands through PHP, as opposed to executing them manually from a Windows shell, the output of BarcodeGenerationTool.exe (a PCL file) contains a different 0x00 padding scheme, compared to when I execute the command manually through the Windows shell. In other words, two different files get outputted depending on where the commands are run (automatically through PHP vs. manual Windows shell), even though both do print out. Any directions on how to detect differences between the two process would help me a lot. By the way, does anyone know of any PHP print to file functions, or of any way to call such functions through PHP (even if not directly)? Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted March 6, 2008 Share Posted March 6, 2008 well file_get_contents will work for the file content issue. The only issue I can see is that your server has a different version of cmd making your syntax slightly off and outputting the extra lines. What you should do is build a second .exe to execute your bargraph perfectly (i.e turn echo off output file creation etc.) and then just exec(BAR_START_FILE.exe) Quote Link to comment Share on other sites More sharing options...
olamur Posted March 6, 2008 Author Share Posted March 6, 2008 The file contents were ok (it does print, but the padding problem prevents post-processing). I made an .exe (in C) to call barcode.bat through system(), but the same kind of problem still arose. Namely, calling the .exe in the Windows shell worked, but calling it through PHP did not. What do you mean by a different version of cmd? I use the same syntax when manually entering commands through the shell. Could you tell me how I could reconfigure the server's (Apache 2.2.6 with defaults I think) cmd stuff? Quote Link to comment Share on other sites More sharing options...
olamur Posted March 7, 2008 Author Share Posted March 7, 2008 bump Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted March 7, 2008 Share Posted March 7, 2008 and u are sure your server is a windows not UNIX? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.