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 DEBIAN
asip-status.pl
ASIP-STATUS.PL(1) Netatalk 2.2 ASIP-STATUS.PL(1)
NAME
asip-status.pl - Queries AFP servers for their capabilities
SYNOPSIS
asip-status.pl [-d] [-i] [-x] HOSTNAME[:PORT]
asip-status.pl -v | -version | --version
DESCRIPTION
asip-status.pl is a perl script that sends a FPGetSrvrInfo request to an AFP server at HOSTNAME:PORT and displays the results, namely
"Machine type", the server's name, supported AFP versions, UAMs and AFP flags, the "server signature" and the network addresses, the server
provides AFP services on.
When you don't supply :PORT, then the default AFP port, 548, will be used.
OPTIONS
-d
Enable debug output.
-i
Show icon if it exists.
-x
Enable hex dump output.
-v, -version, --version
Show version.
EXAMPLES
asip-status.pl 192.168.21.2
AFP reply from 192.168.21.2:548
Flags: 1 Cmd: 3 ID: 57005
Reply: DSIGetStatus
Request ID: 57005
Machine type: Macintosh
AFP versions: AFPVersion 1.1,AFPVersion 2.0,AFPVersion 2.1,AFP2.2
UAMs: Cleartxt passwrd,Randnum exchange,2-Way Randnum exchange
Flags: SupportsCopyFile,SupportsChgPwd,SupportsServerMessages,
SupportsServerSignature,SupportsTCP/IP,SupportsSuperClient
Server name: PowerMac 9600/200
Signature:
04 c1 6e 59 04 c1 6e 59 04 c1 6e 59 04 c1 6e 59 ..nY..nY..nY..nY
Network address: 192.168.21.2:548 (tcp/ip address and port)
Network address: 10.20 (ddp address)
asip-status.pl myserver:10548
AFP reply from myserver:10548
Flags: 1 Cmd: 3 ID: 57005
Reply: DSIGetStatus
Request ID: 57005
Machine type: Netatalk
AFP versions: AFPVersion 1.1,AFPVersion 2.0,AFPVersion 2.1,AFP2.2,AFPX03,
AFP3.1
UAMs: Cleartxt passwrd,Randnum exchange,2-Way Randnum exchange,DHCAST128
Flags: SupportsCopyFile,SupportsServerMessages,SupportsServerSignature,
SupportsTCP/IP,SupportsSrvrNotifications,SupportsOpenDirectory,
SupportsUTF8Servername,SupportsSuperClient
Server name: Fire V480
Signature:
83 29 cc 60 83 29 cc 60 83 29 cc 60 83 29 cc 60 .).`.).`.).`.).`
Network address: 192.168.21.1:10548 (TCP/IP address and port)
Network address: 65282.142 (ddp address)
UTF8 Servername: Fire V480
REPORTING BUGS
Report bugs to the Netatalk-devel list <netatalk-devel@lists.sourceforge.net>.
Netatalk 2.2 02 Sep 2011 ASIP-STATUS.PL(1)