- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Nesting the back tick operator in Perl
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-04-2005 12:15 PM
тАО04-04-2005 12:15 PM
Basically I want to do something like:
`mailx -s "Subject" $dest < \`tail -20 $file\` ';
The escaping of the back ticks did not work as I expected and I get an error like:
_____________
Bareword found where operator expected at ./SigCounter.pl line 53, near "`mailx -s "$msg" $dest < /`tail"
(Missing operator before tail?)
syntax error at ./SigCounter.pl line 53, near "`mailx -s "$msg" $dest < /`tail "
Scalar found where operator expected at ./SigCounter.pl line 53, at end of line
(Missing operator before ?)
_________
I got around it by redirecting the output of the tail to a file, using that file and deleting it but I figure there has to be around this.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-04-2005 01:48 PM
тАО04-04-2005 01:48 PM
Re: Nesting the back tick operator in Perl
`tail -20 $file | mailx -s "Subject" $dest`
- Tags:
- pipe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-04-2005 07:03 PM
тАО04-04-2005 07:03 PM
Solutionsome perl ways. first the answer of Ermin is very good:
qx{tail -20 $file | mailx -s "Subject" $dest};
if you want to do it completely in perl
open my $f, "< $file" or die "Cannot open input: $!";
my @in;
while (<$f>) { $in[$. % 20] = $_ }
close $f;
my $in = ++$. % 20;
open my $m, "| mailx -s Subject $dest";
print $m @in[$in..$#in],@in[0..($in-1)];
close $m;
Or even better, use a mail module:
use Mail::Sendmail;
open my $f, "< $file" or die "Cannot open input: $!";
my @in;
while (<$f>) { $in[$. % 20] = $_ }
close $f;
my $in = ++$. % 20;
sendmail ({To => $dest, From => 'me@here.com', Message => join "", @in[$in..$#in],@in[0..($in-1)]}) or die $Mail::Sendmail::error;
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-05-2005 01:35 PM
тАО04-05-2005 01:35 PM
Re: Nesting the back tick operator in Perl
I am a little surprised that it appears that you cannot pass a back tick pair to a shell.
It comes as no surprise that they cannot be nested in shells.
I always enjoy coding in Perl. I think it is the JAPH thing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-26-2011 09:01 PM
тАО12-26-2011 09:01 PM
Re: Nesting the back tick operator in Perl
>I am a little surprised that it appears that you cannot pass a back tick pair to a shell.
That's why you don't use these archaic back quotes. In a real shell you use $(), which nests.