- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- using awk with open
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
тАО11-25-2008 10:30 AM
тАО11-25-2008 10:30 AM
Here is a little script I have been working on, from a flat file I can get it to work but not from a pipe. print
Any help would be appreciated.
#open(INFO, "iscan.txt");
open(INFO, "ioscan -fnCdisk |awk '\$1==\"disk\" {getline dev; print \$0, dev }|");
$search = "CX3";
while (
if (( /$search/ ) && ( s/^.* $search-[234]0cWDR5 (.*) (.*)$/$2/ )) {
print;
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-25-2008 10:43 AM
тАО11-25-2008 10:43 AM
Re: using awk with open
You want a piped open:
#!/usr/bin/perl
open(INFO, '-|', 'ioscan -fnCdisk' ) or die "Open error: $!\n";
$search = "CX3";
while (
if (( /$search/ ) && ( s/^.* $search-[234]0cWDR5 (.*) (.*)$/$2/ )) {
print;
}
}
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-25-2008 10:54 AM
тАО11-25-2008 10:54 AM
Re: using awk with open
your print command seems to be out of place.
Here's a piece of one of my old ones.
awk 'BEGIN {
while ( "cat '$files' " | getline ) {
entries++
if ( $1 ~ "
}
The print is before the }.
Rita
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-25-2008 11:02 AM
тАО11-25-2008 11:02 AM
Re: using awk with open
If I run the command
ioscan -fnCdisk | awk '$1=="disk" {getline dev; print $0, dev }├в > iscan.txt
the lines are joined. I was hoping to put the complete statement into the open(), and then use INFO with the while. I am trying to script out this process.
Insf -e
Ioscan -fnCdisk
Pvcreate /dev/rdsk/c#t#d#
Lvextend
Lvcreate
Newfs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-25-2008 11:13 AM
тАО11-25-2008 11:13 AM
Solution> I should have clarified better, when I do an ioscan the lines have to be rejoined before use.
OK, but you *still* don't want to mix 'awk' into Perl --- there's no need :-)
#!/usr/bin/perl
use strict;
use warnings;
my $line = '';
my $search = 'CX3';
open(INFO, '-|', 'ioscan -fnCdisk' ) or die "Open error: $!\n";
while (
next if m{^(Class|===)};
chomp;
if ( m{^disk} ) {
$line = $_;
next;
}
$_ = $line . $_;
print "$_\n";
if (( /$search/ ) && ( s/^.* $search-[234]0cWDR5 (.*) (.*)$/$2/ )) {
print;
}
}
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-25-2008 11:33 AM
тАО11-25-2008 11:33 AM
Re: using awk with open
Made quick mod to the prints and it works great now. The hard part will be understanding the new junks of code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-25-2008 11:37 AM
тАО11-25-2008 11:37 AM
Re: using awk with open
Since you are a new member, I'll ask you to please look at this, too:
http://forums11.itrc.hp.com/service/forums/helptips.do?#28
Welcome and Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-25-2008 11:40 AM
тАО11-25-2008 11:40 AM
Re: using awk with open
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-25-2008 11:43 AM
тАО11-25-2008 11:43 AM
Re: using awk with open
>the lines are joined.
Yes, it should do that. Alternately you can use printf then print:
{ printf "%s", $0; getline; print $0 }