Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl system command using grep that return not found error

Status
Not open for further replies.
Aug 14, 2008
38
0
0
US
When I run this code on a linux machine I have no problems; but when done on a Solaris 10 machine I receive the following message back.

Message:
sh: [A-F0-9]: not found
Usage: grep -hblcnsviw pattern file . . .


Code:

#!/usr/bin/perl
my $CHECK = 'mailq|grep ^[A-F0-9]|cut -c 42-80|sort |uniq -c|sort -n|tail > /tmp/qResults';


#create list of top sender emails in the queue
if ( system($CHECK) !=0) {
die "Error excuting $CHECK: error " .
"code " . ($?/256) . "\n";
}

Could someone offer some code to fix this problem.
 
Rewrote the $CHECK variable as

my $CHECK = "mailq|grep '^[A-F0-9]'|cut -c 42-80|sort |uniq -c|sort -n|tail > /tmp/qResults";

This was based on a response given by user PHV.

If their is a simpler complete perl method though I would be interested learing of it to add to my my knowledge base
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top