Bash Script

Hi,

im trying to setup a RBL DNS server for my testing.
im trying to write a bash scrip that add the IP's to add bind zone.

im having a prb transferring the ip in reveres format (192.168.1.2 -->
2.1.168.192)

can any one help me to do this with a bash script ?

thanks a lot
Kev

-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Kev [ Mo, 21 November 2005 05:45 ] [ ID #1066466 ]

RE: Bash Script

Kev, you can use awk for this:)

#!/bin/bash

ip_address=192.168.1.2

reversed=`echo $ip_address | awk 'BEGIN { FS = "."; OFS = "." } ; { print
$4, $3, $2, $1 }'`

echo $reversed

-----Original Message-----
From: linux-admin-owner [at] vger.kernel.org
[mailto:linux-admin-owner [at] vger.kernel.org]On Behalf Of Kev
Sent: Monday, November 21, 2005 3:45 PM
To: 'Linux Mail List'
Subject: Bash Script


Hi,

im trying to setup a RBL DNS server for my testing.
im trying to write a bash scrip that add the IP's to add bind zone.

im having a prb transferring the ip in reveres format (192.168.1.2 -->
2.1.168.192)

can any one help me to do this with a bash script ?

thanks a lot
Kev

-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Cal McPherson [ Mo, 21 November 2005 06:32 ] [ ID #1066467 ]

Re[2]: Bash Script

On Mon, 21 Nov 2005 16:32:37 +1100
Cal McPherson <calm [at] adtec.com.au> wrote:

> #!/bin/bash
>
> ip_address=192.168.1.2
>
> reversed=`echo $ip_address | awk 'BEGIN { FS = "."; OFS = "." } ; { print
> $4, $3, $2, $1 }'`
>
> echo $reversed

Dear Cal,

thank you so much, it worked like a charm !

-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Kev [ Mo, 21 November 2005 09:00 ] [ ID #1066468 ]

Re: Bash Script

At 10:45 +0600 11/21/2005, Kev wrote:
>im having a prb transferring the ip in reveres format (192.168.1.2
>--> 2.1.168.192)
>
>can any one help me to do this with a bash script ?

Pure BASH:

ip=10.1.22.123 # test address

rev="${ip##*.}" # Get last octet
tmp="${ip%.*}" # Strip last octet
rev="${rev}.${tmp##*.}" # Add third octet
tmp="${tmp%.*}" # Strip third octet
rev="${rev}.${tmp#*.}.${tmp%.*}" # Add first two octets (in reverse order)
unset tmp

echo "$rev" # Display reversed address

--
Jeff Woods <kazrak+kernel [at] cesmail.net>

-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Woods [ Mo, 21 November 2005 10:01 ] [ ID #1066469 ]
Linux » gmane.linux.admin » Bash Script

Vorheriges Thema: Hardware Compatibility
Nächstes Thema: X on virtual terminals