Jump to content

Run bat and get output


Worqy

Recommended Posts

Hello.

 

I'm looking for some help to make a script.

The script should  run a .bat file, and get the output from it. (The text from the console).

 

Regards

Worqy

 

 

Pipe the output into a file or variable.

Link to comment
Share on other sites

Use:

print_r($output):

 

Now the output is:

Array ( [0] => [1] => D:\XAMPP\xampp\htdocs>echo a [2] => a [3] => [4] => D:\XAMPP\xampp\htdocs>echo b [5] => b [6] => [7] => D:\XAMPP\xampp\htdocs>pause [8] => Jatka painamalla mit„ tahansa n„pp„int„ . . . ) 

Link to comment
Share on other sites

I now wan't to get the output out of a jar file insted of a batch file.

 

I use the code:

<?php
exec('java -jar D:\test\server.jar', $result);
print $result;
?>

 

When i load the script, it opens the jar file, but the page keeps loading.

Then when I close the jar file, the script stop loading and displays "Array".

 

I would want to get the output of the jar as long as its open.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.