Hi
I have written a bash script to capture the output of jmap.
The command i execute is jmap -heap <pid>
This gives details of memory usage of the process with <pid>.
Now jmap not only gives this info but also prints couple more lines, which i am not interested in. Here are the lines that I am not able to capture and I dont want these lines to be echoed
HTML Code:
Attaching to process ID 20850, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 17.1-b03
I tried to set echo off before executing jmap and set echo on after this statement, but of no use.
set echo off works fine, but it does not turn on later.
Please suggest.
Here is my script
HTML Code:
#!/bin/bash
psdetails=$(ps -ef | grep "$1" | grep -v "grep" | grep -v "heapDataExtractor")
# Get the pid
pid=$(echo $psdetails | awk '{split($0, a," "); print a[2] }')
set echo off
$JAVA_HOME/bin/jmap -heap $pid > jmapRawData.txt
let headerCount=0
set echo on
while read line
do
#do some processing and echo the output
done < jmapRawData.txt