When writing a unix script, I am very confused why the script is erroring out.
The script is this...
jvmpid=$(pidof java)
./jstat -gc $jvmpid
When I run the script, it errors out:
Malformed VM Identifier: 3492 Usage: jstat -help|-options jstat - [-t] [-h] [ []]
Definitions: An option reported by the -options option Virtual Machine Identifier. A vmid takes the following form: [@[:]] Where is the local vm identifier for the target Java virtual machine, typically a process id; is the name of the host running the target Java virtual machine; and is the port number for the rmiregistry on the target host. See the jvmstat documentation for a more complete description of the Virtual Machine Identifier. Number of samples between header lines.
Sampling interval. The following forms are allowed: ["ms"|"s"] Where is an integer and the suffix specifies the units as milliseconds("ms") or seconds("s"). The default units are "ms". Number of samples to take before terminating. -J Pass directly to the runtime system.
However, if I execute each line of the script inside the shell directly, every works fine.
Any clues? I've searched the web for help already.