- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Perl script - piping problem
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
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
тАО05-22-2011 06:40 PM
тАО05-22-2011 06:40 PM
my @args = ( "ipcalc ", $net, "|","grep Wildcard" );
system (@args);
Why am i getting this:
ipcalc 2.1.2.0/20
|grep Wildcard
Rather then this:
ipcalc 2.1.2.0/20 |grep Wildcard
?
Solved! Go to Solution.
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-22-2011 09:30 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-23-2011 05:59 AM
тАО05-23-2011 05:59 AM
Re: Perl script - piping problem
Now what should I do to get rid of the error below ?
#!/usr/bin/perl
open (MYFILE,'/ip/a.txt');
while (
$net = "$_"; #$net = "2.24.0.0/13"
chomp($net);
my @args = ( "ipcalc ", $net, "|","grep Wildcard|awk '{print \$2}' \>> /ip/b.txt" );
$cmd = @args[0].@args[1].@args[2].@args[3];
system ($cmd);
print "$cmd\n";
}
close (MYFILE);
Use of uninitialized value $ENV{"TERM"} in pattern match (m//) at /usr/bin/ipcalc line 714.
ipcalc 83.223.192.0/19|grep Wildcard|awk '{print $2}' >> /ip/b.txt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-23-2011 06:15 AM
тАО05-23-2011 06:15 AM
Re: Perl script - piping problem
> Now what should I do to get rid of the error below ?
Use of uninitialized value $ENV{"TERM"} in pattern match (m//) at /usr/bin/ipcalc line 714.
ipcalc 83.223.192.0/19|grep Wildcard|awk '{print $2}' >> /ip/b.txt
The environmental 'TERM' variable isn't set. Either set it before you run your script, or (better) test for "defined-ness" before referencing it. This will need to be done in '/ipcalc' --- the code for which you don't show.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-23-2011 06:35 AM
тАО05-23-2011 06:35 AM
Re: Perl script - piping problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-23-2011 06:59 AM
тАО05-23-2011 06:59 AM
Re: Perl script - piping problem
> But ipcalc is a Linux utility.
Then set the TERM variable to something in your script or on the command line!
# TERM=vt100 ./Piotr_Script
...Notice that there is whitespace after the setting without any semicolon before the run of your script. That sets the environmental variable only for the duration of your script.
Otherwise in your script do something like this shows:
# perl -le 'local $ENV{TERM}='vt100';print "[$ENV{TERM}]"'
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-23-2011 10:10 AM
тАО05-23-2011 10:10 AM
Re: Perl script - piping problem
Did this solve your problem?
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-23-2011 02:47 PM
тАО05-23-2011 02:47 PM
Re: Perl script - piping problem
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-23-2011 03:40 PM
тАО05-23-2011 03:40 PM
Re: Perl script - piping problem
How do I get the output of $cmd to a perl variable.
$var = $cmd doesn't work.
#!/usr/bin/perl
system ("TERM=vt100");
local $ENV{TERM}='vt100';
#print "[$ENV{TERM}]"';
open (MYFILE,'/ip/a.txt');
while (
$net = "$_"; #$net = "2.24.0.0/13"
chomp($net);
my @args = ( "ipcalc ", $net, "|","grep Wildcard|awk '{print \$2}' \>> /ip/b.txt" );
$cmd = @args[0].@args[1].@args[2].@args[3];
system ($cmd);
}
close (MYFILE);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-23-2011 03:53 PM
тАО05-23-2011 03:53 PM
Re: Perl script - piping problem
> How do I get the output of $cmd to a perl variable.
The simplest way, when you don't care about the return code is to use backticks:
# perl -le '$result=`uname -a`;print $result'
If you dislike the backticks use 'qx( .... )':
# perl -le 'perl -le '$result=qx(uname -a);print $result'
Regards!
...JRF...