Question relate to AWK


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Question relate to AWK
# 8  
Old 04-25-2008
The outfile still very messy.

It looks like this:

10.72.169.110.72.169.210.72.169.310.72.169.410.72.169.510.72.169.610.72.169.710.72.169.810.72.169.91 0.72.169.1010.72.169.1110.72.169.1210.72.169.13datafeeds
Red Hat Enterprise Linux AS release 3 (Taroon)
10.72.169.1410.72.169.1510.72.169.16xenon.devo.ilx.com
Fedora Core release 5 (Bordeaux)
10.72.169.1710.72.169.1810.72.169.1910.72.169.2010.72.169.21lumines.devo.ilx.com
Fedora Core release 5 (Bordeaux)
10.72.169.2210.72.169.2310.72.169.24


However, someone of ip address maybe dead or no one using it. Does it make any different?
# 9  
Old 04-25-2008
I don't understand how you would get that output. Are you running the script exactly like I wrote it, just with an additional backquote after .../etc/redhat-release"?
# 10  
Old 04-25-2008
You could also put the IP address inside the ssh command; then you don't get any output from hosts which don't respond.

Code:
for i in $(seq 1 254)
do
    ssh -o ConnectTimeout=3 root@10.72.169.$i "echo 10.72.169.$i `hostname` `cat /etc/redhat-release`"
done >result

# 11  
Old 04-25-2008
I want the host ip to show up even though the ip isn't being used or dead, so i used the below script and now it only turns all numbers in single line...

for i in $(seq 1 254)
do
echo -n 10.72.169.$i >> result2
ssh -o ConnectTimeout=3 root@10.72.169.$i "hostname; cat /etc/redhat-release'" >> result2
done



RESULT:

10.72.169.110.72.169.210.72.169.310.72.169.410.72.169.510.72.169.610.72.169.710.72.169.810.72.169.91 0.72.169.1010.72.169.1110.72.169.1210.72.169.1310.72.169.1410.72.169.1510.72.169.1610.72.169.1710.72 .169.1810.72.169.1910.72.169.2010.72.169.2110.72.169.2210.72.169.2310.72.169.24
# 12  
Old 04-25-2008
Try variablizing the results:

Inside the loop:
host=`echo 10.72.169.$i`
server=`ssh -o ConnectTimeout=3 root@10.72.169.$i 'hostname'`
release=`ssh -o ConnectTimeout=3 root@10.72.169.$i 'cat /etc/redhat-release'`

then:
echo "$host $server $release" >> result
echo >> result

Hope this helps.
# 13  
Old 04-25-2008
Thanks.

How how can I put a title in the output file?

For example:

IP Address HOSTNAME VERSION
10.72.169.1 abc fedora 5
10.72.169.2 ded fedora 5

Thanks again.
# 14  
Old 04-25-2008
You can use the '-e' switch with 'echo' and add tabs to line everything up:

echo -e "IP ADDRESS\t\tHOSTNAME\t\tRELEASE" >> result
echo -e "10.x.x.x\t\thostname\t\trelease" >> result

Hope this helps.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

How to relate ipcs id or cpid to process?

Hi, we have multiple database instances running on solaris server like db1, db2 and db3. Below shown ipcs -pmb shared memory segment output. Using cpid value I want to relate to the database instances db1, db2 and db3. Please let me know how to do this? $ ipcs -pmb IPC status from <running... (9 Replies)
Discussion started by: baladelaware73
9 Replies

2. Shell Programming and Scripting

awk question : system output to awk variable.

Hi Experts, I am trying to get system output to capture inside awk , but not working: Please advise if this is possible : I am trying something like this but not working, the output is coming wrong: echo "" | awk '{d=system ("date") ; print "Current date is:" , d }' Thanks, (5 Replies)
Discussion started by: rveri
5 Replies

3. Shell Programming and Scripting

question about awk

Mike Harrington:(510) 548-1278:250:100:175 Christian Dobbins:(408) 538-2358:155:90:201 Susan Dalsass:(206) 654-6279:250:60:50 Archie McNichol:(206) 548-1348:250:100:175 Jody Savage:(206) 548-1278:15:188:150 Guy Quigley:(916)... (4 Replies)
Discussion started by: JA50
4 Replies

4. Programming

help with C++ code that relate the object with physical address

I need some help to write a C++ code that read and write the register of a sequencer. I have to make a code that relate the objects with the physical address but I am a bit confuse. Could someone suggest me how to proceed? in which parts do I split the code? thanks (1 Reply)
Discussion started by: silviafisica
1 Replies

5. Solaris

I have LUN ID, how to find disk relate to that LUN ID?

I have a list of LUN ID, my task is to find if disk has been added or not. How do I do that? I have been searching the forum and not able to find answer. thanks (4 Replies)
Discussion started by: uuontario
4 Replies

6. UNIX for Dummies Questions & Answers

Basic awk question...getting awk to act on $1 of the command itself

I have a script problem that I am not able to solve due my very limited understanding of unix/awk. This is the contents of test.sh awk '{print $1}' From the prompt if I enter: ./test.sh Hello World I would expect to see "Hello" but all I get is a blank line. Only then if I enter "Hello... (2 Replies)
Discussion started by: JasonHamm
2 Replies

7. Shell Programming and Scripting

Need to relate Radius log entries to DHCP ones

Hi, let say i have 2 log files(they are below) dhcp and radius. What i need is to put the information to a file just from good connections ( Auth: Login OK ) others just ignore. And the information should look like: time, login name, mac, ip, server. But the trouble is that from radius log i get... (10 Replies)
Discussion started by: wrwe
10 Replies

8. HP-UX

question on awk

i have bench of files and i have archeive in different names FOR EX: the files come in the directory as 1111_2222_3333_4444_5555_6666_7777.dat.xls.ZIP XXXX_VVVV_3333_4444_5555_6666_7777.dat.xls.ZIP I have to select the files from 4 th position to last position and concaTENATE THEM ... (1 Reply)
Discussion started by: r_satya7
1 Replies

9. Shell Programming and Scripting

awk .. question?

i have a little awk script that I use looks this: awk '{if (FNR==1){print FILENAME; print $0}else print $0}' file1...file2....fi... > bundled. i have completely forgotten how to unbundle this. I have tried several different approaches and still can not remember how to unbundle the file bundled.... (2 Replies)
Discussion started by: moxxx68
2 Replies

10. Shell Programming and Scripting

Another Awk Question! ;)

The variable "NF" holds the number of fields on the current record. Is there a variable that returns the current field within the record being processed? Given a record of "n" fields (variable number of fields for a given record), how can you tell which field you are actually on when you match a... (5 Replies)
Discussion started by: google
5 Replies
Login or Register to Ask a Question