08-29-2009
print ip to hostname with array
Hi Anyone can help me??i writing a perl using array to translate ip address to the hostname my script are below.this line print "$myhost{$ipaddr}\n"; blank
hostname dint come out
#!/usr/local/bin/perl
@ipaddr=("192.1.168.2","172.25.1.13","129.1.2.5");
%myhost = { 192.1.168.2 =>"Machine 1",172.25.1.13=>"Machine 2",129.1.2.5=>"Machine 3");
foreach $ipaddr(@ipaddr){
print "$ipaddr\n";
print "$myhost{$ipaddr}\n";
}
---------- Post updated at 11:22 AM ---------- Previous update was at 11:16 AM ----------
fyi i have try
print "$myhost{192.1.168.2}";
supposely come out Machine 1 but nothing comeout...blank!!
.anyone pls help me..
---------- Post updated at 11:25 AM ---------- Previous update was at 11:22 AM ----------
this line print "$ipaddr\n"; no problem can print out the ip addre
192.1.168.2
172.25.1.13
129.1.2.5
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hello,
I am new to Solaris.
I am using stand alone Solaris 10.0 for test/study purpose and connecting to internet via an ADSL modem which has DHCP server. My Solaris is working on VMWare within winXP. My WinXP and Solaris connects to internet by the same ADSL modem via its DHCP at the same... (1 Reply)
Discussion started by: XNOR
1 Replies
2. Shell Programming and Scripting
Hey,
I'm trying to print the first four characters of the hostname of a computer.
I can get it from using:
hostname -s | sed 's/...........$//'"
but this is when I know how many characters are in the computer name.
I dont understand why some like:
hostname -s | sed '/..../p'
wont... (7 Replies)
Discussion started by: yxian
7 Replies
3. Shell Programming and Scripting
The code below prints outs each array element, but it always says the array length is 1 even though its not. What am i doing wrong?
function printArray(){
#here should check if it is an array and that an arg exits
echo "Priting array"
myarr="${@}"
echo... (2 Replies)
Discussion started by: chrisjones
2 Replies
4. Emergency UNIX and Linux Support
Hi All,
So we added a new HP-UX 11.31 machine. Copied OS via Ignite-UX (DVD)over from this machine called machine_a. It was supposed to be named machine_c. And it is when you log in...however when I'm in the ILO console before logging in, it says:
It should say:
What gives? And how do... (4 Replies)
Discussion started by: zixzix01
4 Replies
5. Shell Programming and Scripting
Hi, as the title, I have an array @f_lines with gene information in it. How can I put the content of @f_lines into a file so that I can read it?
I tried this:
open(OUTPUT, "file"); # put gene information in this file;
@f_lines = ("gene1", "gene2", "gene3"...); # gene information;
print... (3 Replies)
Discussion started by: lyni2ULF
3 Replies
6. UNIX for Dummies Questions & Answers
Hello,
May i please know how do i print the array using awk script. I am using below shell script to start with but not working.
#!/bin/bash
LOADSTATUS="Line 0"
LOADSTATUS="Line 1"
LOADSTATUS="Line 2"
LOADSTATUS="Line 3"
LOADSTATUS="Line 4"
awk '
BEGIN {
Your File Load Status
}... (1 Reply)
Discussion started by: Ariean
1 Replies
7. UNIX for Advanced & Expert Users
deleted (0 Replies)
Discussion started by: hce
0 Replies
8. Shell Programming and Scripting
I have test.sh file as below :
set -A IDARR $ID
echo | awk -f test.awk -v TempArr="${IDARR
}"
I have test.awk file as below :
BEGIN {
Flag = 1;
}
{
print "Hello";
for(i in TempArr)
{
print i;
}
} (9 Replies)
Discussion started by: nes
9 Replies
9. Shell Programming and Scripting
Hi
How to pass echo output to a variable ?
Does below awk command will get the last character of hostname and assign to a variable - "svr" ?
svr=$( echo `hostname` | awk '{print substr($0,length,1)}' )
Thanks.
Please use CODE tags when dsplaying code segments, sample input, and sample... (7 Replies)
Discussion started by: Lim
7 Replies
10. Shell Programming and Scripting
Hi all,
i'm trying to gether multiple pattern on remote hosts, and trying to print hostname and the pattern,
ssh remoteserver1 -C 'hostname 2>&1;cat /var/log/server1.log | awk -F ";" '"'"'{ print " "$2" "$5}'"'"'| sort | uniq -c | sort -g -r '
The output is the following,
remoteserver1
... (8 Replies)
Discussion started by: charli1
8 Replies
LEARN ABOUT CENTOS
unbound-streamtcp
unbound-streamtcp(1) unbound unbound-streamtcp(1)
NAME
unbound-streamtcp - unbound DNS lookup utility
SYNOPSIS
unbound-streamtcp [-unsh] [-f ipaddr[@port]] name type class
DESCRIPTION
unbound-streamtcp sends a DNS Query of the given type and class for the given name to the DNS server over TCP and displays the response.
If the server to query is not given using the -f option then localhost (127.0.0.1) is used. More queries can be given on one commandline,
they are resolved in sequence.
The available options are:
name This name is resolved (looked up in the DNS).
type Specify the type of data to lookup.
class Specify the class to lookup for.
-u Use UDP instead of TCP. No retries are attempted.
-n Do not wait for the answer.
-s Use SSL.
-h Print program usage.
-f ipaddr[@port]
Specify the server to send the queries to. If not specified localhost (127.0.0.1) is used.
EXAMPLES
Some examples of use.
$ unbound-streamtcp www.example.com A IN
$ unbound-streamtcp -f 192.168.1.1 www.example.com SOA IN
$ unbound-streamtcp -f 192.168.1.1@1234 153.1.168.192.in-addr.arpa. PTR IN
EXIT CODE
The unbound-streamtcp program exits with status code 1 on error, 0 on no error.
AUTHOR
This manual page was written by Tomas Hozza <thozza@redhat.com>.
NLnet Labs Mar 21, 2013 unbound-streamtcp(1)