Bash Script

Bash Script

am 21.11.2005 05:45:24 von Kev

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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

RE: Bash Script

am 21.11.2005 06:32:37 von Cal McPherson

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@vger.kernel.org
[mailto:linux-admin-owner@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@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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

Re[2]: Bash Script

am 21.11.2005 09:00:56 von Kev

On Mon, 21 Nov 2005 16:32:37 +1100
Cal McPherson 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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: Bash Script

am 21.11.2005 10:01:05 von Jeff Woods

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

-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html