0

I have this file batch (test.bat), that contains these

javac c:\Hello.java

I can run this batch file using PHP ..

<?php
system("cmd /c C:\\test.bat");
?>

but I want to enter the name of java file from PHP code how can I send this parameter to batch file,, what is the required modifications in batch file and php code ?

5
  • Why you don't bypass the scrippt and call the java compiler directly? Commented Jul 11, 2011 at 16:49
  • That doesn't make much sense :? Commented Jul 11, 2011 at 16:55
  • Of course, it did :) , thnaks Commented Jul 11, 2011 at 16:56
  • You posted the content of the batch file above. How can you don't know it? (Thats the point, that seems illogical to me ;)). Commented Jul 11, 2011 at 17:01
  • I mean this command :) exec("javac c:\Hello.java"); Commented Jul 11, 2011 at 17:02

1 Answer 1

1

will work:

  <?php
    exec("javac c:\Hello.java");
  ?>
Sign up to request clarification or add additional context in comments.

3 Comments

after the command string, you can pass a variable (e.g $output that will be an array), if the script return something, each output line will be added to this variable, after you need just interate into this array to view tha output
can I use cd command with exec ... such as exec("cd c:\\test\\".$projectName);
cd is an internal command, you need to invoke it cmd /c cd ..

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.