Taeky Taeky - 1 year ago 70
Linux Question

How to manipulate the output of a .jar file and print it in a file or PHP variable

I'm trying to manipulate the output of


/usr/bin/java -jar /home/rpteira/jmxcmd.jar - my_machine:myport mybeanname > out.txt

This prints in the
file a list with all the available attributes and commands of
but when I want to execute an special command of
I see the result in the console but not in the
file. For example:

/usr/bin/java -jar /home/rpteira/jmxcmd.jar - my_machine:myport mybeanname getSomeStuff > out.txt

The shell output is something similar to this, but nothing in the file.

dd/mm/yyyy hh:mm:ss -0400 de.layereight.jmxcmd.Client getSomeStuff: 0

I want the 0 displayed above. To go further I would like to manipulate the result from php using
but I can't find the output in my variable in this second case so I think this issue might be correlated.

What can I do?

Answer Source

Change your command line pattern from

cmd > out.txt


cmd &> out.txt

This will output both, standard output and errors, into out.txt.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download