linux - 如何在 linux 中使用 perl 从显示的输出中提取数字

标签 linux perl shell unix jmx

# This Perl script open connection and call domains
# $jar stands for path of jmxterm jar file

open JMX, "| java -jar jmxterm-1.0-alpha-4-uber.jar -n"; // jmx jar file 
#print JMX "help \n";

my $host = "127.0.0.1"; // hostname
my $port = 7199; //jmx port number

print JMX "open $host:$port\n";
#print JMX "domains\n";
print JMX "domain org.apache.cassandra.request\n";
print JMX "bean type=ReadRepairStage\n";
print JMX "get CompletedTasks\n"; 
print JMX "close\n";
close JMX;

目前,我得到的输出为 CompletedTasks = 1234,我需要 1234

最佳答案

您不能使用简单的open 来建立双向通信。参见 IPC::Open2了解更多。

关于linux - 如何在 linux 中使用 perl 从显示的输出中提取数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14337133/

相关文章:

json - Perl,检查各种类型的哈希值是否为空键值,json

linux - 如何使用shell实时连续处理tail -f换行?

linux - 用于删除另一个文件夹中不存在的文件和文件夹的 Shell 脚本

c - 用户定义信号 1

linux - linux shell 中的特殊字符

linux - 在 shell 脚本中读取第一行后读取多行输出停止

perl - 不使用 pause.perl.org 将模块上传到 CPAN

perl - 如何最好地在 Moose 中使用默认设置触发访问器?

java - 编写仅接受参数的 `jjs` shebanged 脚本

bash - 使用 nohup 运行 JMeter 脚本