Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

Help with a shell script

Original Message
Name: jrmontg
Date: July 11, 2006 at 08:15:23 Pacific
Subject: Help with a shell script
OS: UNIX
CPU/Ram: Intel Xeon
Model/Manufacturer: HP
Comment:
I need a file to run a ndstat -l and find the line "Interface speed: 1000 Mbits/sec" and extract the 1000 Mbits/sec and add it to a file.

Thanks for the help

jrmontg


Report Offensive Message For Removal


Response Number 1
Name: nails
Date: July 11, 2006 at 10:12:45 Pacific
Subject: Help with a shell script
Reply: (edit)

Typical output of the ndstat -l command looks like this (# comments are mine):

# start ndstat output
DLPI Module Info: 2 SAPs open, 16 SAPs maximum

96687 frames received destined for an unbound SAP

MAC Driver Info: Media_type: Ethernet
Min_SDU: 14, Max_SDU: 1514, Address length: 6
Interface speed: 1000 Mbits/sec
# End ndstat output

How about an awk script that searches for the first two fields equal "Interface" & "speed:" and print everything from field 3 to the end of the line:

#!/bin/ksh
# myscript.ss

ndstat -l|awk ' { if( $1 == "Interface" && $2 == "speed:")
for(i=3; i <= NF; i++)
printf("%s ", $i) } '

I don't know what "add it to a file" means, but executing:

myscript.ss >> new.file

appends the output of myscript.ss to new.file



Report Offensive Follow Up For Removal

Response Number 2
Name: jrmontg
Date: July 11, 2006 at 11:37:56 Pacific
Subject: Help with a shell script
Reply: (edit)
Thanks
that script got me this:
1000 Mbites/sec 1000 Mbites/sec
Is there a way just to get it to list it once?

jrmontg


Report Offensive Follow Up For Removal

Response Number 3
Name: nails
Date: July 11, 2006 at 12:26:56 Pacific
Subject: Help with a shell script
Reply: (edit)
Without seeing the output of your 'ndstat -l' command, I can't tell for sure. It looks like you have two different lines that have the same output. If that's the case, why don't you exit the awk script after the first one:

ndstat -l|awk ' { if( $1 == "Interface" && $2 == "speed:")
for(i=3; i <= NF; i++)
{
printf("%s ", $i)
if(i == NF)
exit(0)
}
} '


Report Offensive Follow Up For Removal




Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Help with a shell script

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




Batch File- Current Date in Excel

how to setup call of duty to joytok

WindowsME / HotMail Problem

Corrupt memory

Convert fat32 to Ntfs


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC