- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Script help - reading mulple lines into variab...
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
тАО06-01-2004 12:50 AM
тАО06-01-2004 12:50 AM
Any examples to share?
Thanks...
Jack
----------------------------------
Example:
while read -r field1 field2 field3 field4 field5 field6 field7 field8 field9 field10
do
echo $field1
done < lanscan | grep -v "^Path" | grep -v "^Hardware" | awk ' { print $1 " " $2 " " $3 " " $4 \ " " $5 " " $6 " "
$7 " " $8 " " $9 " " $10 } '
---------------------------------
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-01-2004 01:33 AM
тАО06-01-2004 01:33 AM
Solution#!/usr/bin/perl
open(INFILEPTR,"lanscan |") || die "unable to find lanscan";
while (
next if (grep(/^Path/,$_));
next if (grep(/^Hardware/,$_));
tr/ / /s;
($field1, $field2, $field3, $field4, $field5, $field6, $field7, $field8, $fie
ld9, $field10) = split(/ /);
print $field1,"_" ,$field2,"_", $field3,"_", $field4,"_", $field5,"_", $field6,"_", $field7,"_", $field8,"_", $field9,"_", $field10;
}
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-01-2004 01:38 AM
тАО06-01-2004 01:38 AM
Re: Script help - reading mulple lines into variables from command execution
Jack...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-01-2004 02:29 AM
тАО06-01-2004 02:29 AM
Re: Script help - reading mulple lines into variables from command execution
lanscan |
grep -v "^Path" |
grep -v "^Hardware" |
awk ' { print $1 " " $2 " " $3 " " $4 \ " " $5 " " $6 " "$7 " " $8 " " $9 " " $10 } ' |
while read -r field1 field2 field3 field4 field5 field6 field7 field8 field9 field10
do
echo $field1
done
instead of all the greps and awk you could just do
awk '
/^Path/ {next;}
/^Hardware/ {next;}
{ print $1 " " $2 " " $3 " " $4 \ " " $5 " " $6 " "$7 " " $8 " " $9 " " $10 } '
or
while read -r field1 field2 field3 field4 field5 field6 field7 field8 field9 field10
do
echo $field1
done < $(lanscan | grep -v "^Path" | grep -v "^Hardware" | awk ' { print $1 " " $2 " " $3 " " $4 \ " " $5 " " $6 " "
$7 " " $8 " " $9 " " $10 } ')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-01-2004 02:54 AM
тАО06-01-2004 02:54 AM
Re: Script help - reading mulple lines into variables from command execution
Jack
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-01-2004 03:46 AM
тАО06-01-2004 03:46 AM
Re: Script help - reading mulple lines into variables from command execution
\
before the $5
Rgds...Geoff
lanscan | awk ' ^J/^Path/ {next;}^J/^Hardware/ {next;}^J{ print $1 " " $2 " " $3 " " $4 " " $5 " " $6 " "$7 " " $8 " " $9 " " $10 } '
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-01-2004 03:50 AM
тАО06-01-2004 03:50 AM
Re: Script help - reading mulple lines into variables from command execution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-01-2004 05:53 AM
тАО06-01-2004 05:53 AM
Re: Script help - reading mulple lines into variables from command execution
lanscan | grep -v "^Path" | grep -v "^Hardware" | awk ' { print $1 " " $2 " " $3 " " $4 " " $5 " " $6 " "
$7 " " $8 " " $9 " " $10 } ' |&
while read -rp field1 field2 field3 field4 field5 field6 field7 field8 field9 field10
do
echo $field1
done
hey 2 out of 3 ain't bad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-01-2004 06:17 AM
тАО06-01-2004 06:17 AM
Re: Script help - reading mulple lines into variables from command execution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-01-2004 06:22 AM
тАО06-01-2004 06:22 AM