- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: how to substitute variable in awk.
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
тАО02-09-2005 08:14 PM
тАО02-09-2005 08:14 PM
I want check if all my servers are up by this script, can any one help me with 2 issues
1) How to insert variable in awk (awk '$1 == "$a" { print $0 } ' /etc/hosts )
2) How to set timeout for ping ?
#!/bin/sh
for a in
` sed -n '/202/p' /usr/scripts/ping_server.sh | awk ' { print $1 } '`
do
echo pinging $a
flag=`ping $a -n 3`
echo $flag | grep -i '0% packet loss'
echo $?
if [ "$?" -eq 0 ]
then
h=`awk '$1 == "$a" { print $0 } ' /etc/hosts `
echo " $h Host Alive "
fi
done
Waitn for u r responce.
Rgds
Ankur
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2005 08:32 PM
тАО02-09-2005 08:32 PM
Solutionman awk tells you to use -v parameter
awk -v myvar=$a '{print myvar}' filename
But
A far better method to check to see if your hosts are up is to use ruptime.
vi /etc/rc.config.d/netdaemons
set RWHOD=1
start rwhod
then, define host equivalence for your machines.
$ ruptime
It will run uptime on all your remote systems and list them all at once. It also shows the load on each machine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2005 08:50 PM
тАО02-09-2005 08:50 PM
Re: how to substitute variable in awk.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2005 08:51 PM
тАО02-09-2005 08:51 PM
Re: how to substitute variable in awk.
export A=2
awk '{p=ENVIRON["A"];print p}'
2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2005 10:49 PM
тАО02-09-2005 10:49 PM
Re: how to substitute variable in awk.
Im happy.
For laurant : awk: Field $() is not correct.
The input line number is 1. The file is /etc/hosts.
The source line number is 1.
Steve's thing worked , but had to some tweakin.
Regards
Ankur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2005 10:53 PM
тАО02-09-2005 10:53 PM
Re: how to substitute variable in awk.
This is how we can address variable "a" in awk.
awk '$1 == ENVIRON["a"]
{ print $0 } ' /etc/hosts