私は次のことをしています:
#!/usr/bin/perl
use strict;
use warnings;
my $proc = `ps -ef|grep -c myscriptname`;
print $proc;
これをスクリプト内で実行すると、2 が出力されます。
ps -ef|grep -c myscriptname
コマンドラインで次のように表示されます:1
なぜですか?
同じmy $proc = qx/ps -ef|grep -c myscriptname/
更新
明確にするために、このスニペットをから実行しますsomerandomscript.pl
更新 2
edorqui のアドバイスに従って、次の取得を削除-c
します。
12013 15777 15776 0 14:11 pts/6 00:00:00 sh -c ps -ef | grep myscriptname
12013 15779 15777 0 14:11 pts/6 00:00:00 grep myscriptname Argument "12013 15777 15776 0 14:11 pts/6 00:00:00 sh -c ps..." isn't numeric in numeric gt (>) at somerandomscript.pl line 8
スクリプトの中から