- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Bourne Shell script writing
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
Forums
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
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-08-2002 04:03 PM
тАО04-08-2002 04:03 PM
Please advise/help me in writing a script for the following practical situation;
The IP addresses of the computers in the company's solaris and linux labs are
grouped into ranges of thirty. It seems there's not an exact match between the "physical" and "logical" location of computers- so machines in the same
IP address range aren't necessarily located in the same classroom at the moment. The IP address ranges for each group of computers is:
Group A 138.25.9.80 - 138.25.9.109
Group B 138.25.9.110 - 138.25.9.139
Group C 138.25.9.180 - 138.25.9.209
Group D 138.25.9.210 - 138.25.9.239
Group E 138.25.11.60 - 138.25.11.89
Write a (Bourne!) shell called macfinder that gathers the MAC address and hostname for each machine in the lab. The script should accept the first IP address in the range and the Room or Group description as it's arguments. It
should write its output (30 records) to stdout. The data file format will
have the following structure:
IP Address,MAC Address,Hostname,Location or Group
for example
138.25.8.2,00:03:ba:01:7a:72,charlie,Server Room on level 3
138.25.9.1,08:00:20:fc:fa:47,linus,Server Room on level 3
The command could be issued like this
./macfinder 138.25.9.80 FIT Solaris Machines in Group A >> Part1.dat
Hint: The commands arp, ping and nslookup will be of some help in gathering
the information you require to create your records.
Thanks a lot in advance
Nisar
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2002 04:43 PM
тАО04-08-2002 04:43 PM
Re: Bourne Shell script writing
What part of your script have you written so far? There are exceptions to every rule but generally people posting have made an attempt to write their own script and request assistance in correcting problems they encounter.
Of course, someone could be bored and decide to write the complete script for you.
Good luck!
Darrell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2002 05:04 PM
тАО04-08-2002 05:04 PM
Re: Bourne Shell script writing
From the range of IP addresses, I would presume that your labs are all in a single Ethernet broadcast domain i.e. there is no need to route between labs. This presumption is needed for arp to be useful. Otherwise, you will only be getting the MAC address of your router.
If it is a single Ethernet broadcast domain, you can perform something like the following in your script:
# ping broadcast address
ping 138.25.9.255
# list out MAC addresses, server names, IP addresses:
arp -a
arp -a will attempt to perform a name resolution on the IP addresses. Use awk to parse the output to print out the relevant fields in the correct order.
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-09-2002 02:56 AM
тАО04-09-2002 02:56 AM
Re: Bourne Shell script writing
HP Education have a course that will definitely help you write this script. It is called POSIX Shell Programming and will teach you the skills you need to write POSIX, Bourne and Korn shell scripts.
See http://education.hp.com for more info
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-09-2002 03:11 AM
тАО04-09-2002 03:11 AM
SolutionFor script examples look at
http://www.introcomp.co.uk/hpux/index.html
Just get each machien to mail you its info daily . Or collect it to a file and ftp to a central point.
Steve Steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-09-2002 03:24 AM
тАО04-09-2002 03:24 AM
Re: Bourne Shell script writing
This looks remarkable like an instructor / exam paper question.
The HINT bit at the end should guide you.
Ping
Arp
Nslookup
Look at man arp, ping and nslookup.
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-09-2002 03:56 AM
тАО04-09-2002 03:56 AM
Re: Bourne Shell script writing
The shell really doesn't matter because there is nothing shell related.
#!/usr/bin/ksh
#
# ping broadcast address
#
ping 138.25.9.255
#
# arp, cut the fields, pretty up the output, then sort into temporary file
#
arp -a|cut -d" " -f2,4|sed -e "s/(//" -e "s/)//" -e "s/ /,/" | sort >/tmp/macsin
put
#
# join the two files
#
join -j 1 -t, -e "NOT DEFINED" -o 2.1,2.2,1.3 /tmp/macsDB /tmp/macsinput >/tmp/n
ew_macsDB
#
# rename new file
#
mv /tmp/new_macsDB /tmp/macsDB
You have to maintain "/tmp/macsDB" with your favorite editor (vi).
Actually, thinking about this a little more, the above script won't catch some things. This is really a case for perl, the use of the bourne shell is really silly.
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-09-2002 04:37 AM
тАО04-09-2002 04:37 AM
Re: Bourne Shell script writing
you can do it like the attached script.
John.