Page 1 of 1

Change all connected IP sets mode to Alcatel Dynamic

Posted: 09 Mar 2016 03:22
by Maulwurf
Hi all,

found at BPWS script to change static IP sets to dynamic. The attached script will change all the connected IPT mode to Alcatel Dynamic.
In my lab (OXE VMware 11.2-l2.300-25-c-de-c0) i get the following error:

(1)xa000000>
(1)xa000000> cd /tmpd
(1)xa000000> chmod 777 iptouch_dhcp.sh
(1)xa000000> chmod 777 all_iptouch_dhcp.sh
(1)xa000000> ./all_iptouch_dhcp.sh

-- Auto Script
-- Copyright 2014. Alcatel-Lucent Technical Support
Reading the list of IPtouch phones...



/tmpd/iptouch_dhcp.sh: line 1: IPv4: command not found
...: Unknown server error
/tmpd/iptouch_dhcp.sh: line 1: IPv4: command not found
/tmpd/iptouch_dhcp.sh: line 42: return: ...: numeric argument required
/tmpd/iptouch_dhcp.sh: line 42: return: ...: numeric argument required
.........: Unknown server error

Task Finished.
Wed Mar 9 09:09:22 CET 2016
(1)xa000000>


Can you help me to solve this?

Re: Change all connected IP sets mode to Alcatel Dynamic

Posted: 09 Mar 2016 07:34
by sadim
Hello,

Please attach both shell files (iptouch_dhcp.sh and all_iptouch_dhcp.sh)

Regards

Re: Change all connected IP sets mode to Alcatel Dynamic

Posted: 09 Mar 2016 13:34
by Maulwurf
Here are the files

Re: Change all connected IP sets mode to Alcatel Dynamic

Posted: 09 Mar 2016 14:43
by sadim
Hello,

Check the contentes of the file /tmpd/listipt

Regards

Re: Change all connected IP sets mode to Alcatel Dynamic

Posted: 10 Mar 2016 02:17
by Maulwurf
Hi sadim,

that my listipt:
|100 |RH1 |00:80:9f:88:1e:7c |S|02100| IPv4 | 192.168.100.176| Unused| Ipt| GE| - |
|102 |RH3 |00:80:9f:a4:07:c8 |S|02128| IPv4 | 192.168.100.175| Unused| Ipt| GE| - |

Both IP Phones have static IP.

Re: Change all connected IP sets mode to Alcatel Dynamic

Posted: 10 Mar 2016 09:40
by sadim
Hello,

The Shell script is OXE version dependent. You need to replace the contents of the file iptouch_dhcp.sh with:

#!/bin/bash
# THIS SCRIPT IS DESIGNED FOR setting dhcp to alcatel dynamic
# Copyright 2014. Alcatel-Lucent Technical Support

# INPUT PARAMETERS VERIFICATION

echo
echo \-\- Auto Script for setting iptouch dhcp to alcatel dynamic
echo \-\- Copyright 2014. Alcatel-Lucent Technical Support
echo
echo `/bin/date`
echo
while read LINE
do

# GET EXTENSION NUMBER & IP INFORMATION

LINE="${LINE//[[:space:]]/}"

eval `echo $LINE|awk -F "|" '{print "EXT="$2}'`
eval `echo $LINE|awk -F "|" '{print "IP="$8}'`

# SPLIT IP TO 4 PARTS

IP1=${IP:0:3}
IP2=${IP:4:3}
IP3=${IP:8:3}
IP4=${IP:(-3)}

# REMOVE ADDITIONAL ZEROS FROM IP ADDRESS

function remzero {
local INPUT=$1
if [ ${#INPUT} -ge 1 ]
then
if [ ${INPUT:0:1} = "0" ]
then
INPUT=${INPUT:1:2}
remzero $INPUT
INPUT=$rtn
fi
fi
rtn=$INPUT
return $rtn;
}

remzero $IP1
IP1=$rtn
remzero $IP2
IP2=$rtn
remzero $IP3
IP3=$rtn
remzero $IP4
IP4=$rtn
IP=$IP1.$IP2.$IP3.$IP4

#PROCESS THE CONFIGURATION CHANGE

echo Enabling Telnet Service for IP address $IP Extension $EXT ...
echo `/usr2/oneshot/mtcl/tool ippstat telnet d $EXT t 1440`
echo
sleep 5
echo Setting config boot information from $IP Extension $EXT ...
echo `(sleep 2;echo "config dhcp a";sleep 2; echo "reset";sleep 2) | /usr/bin/te
lnet $IP`
echo
echo
echo done.
sleep 2
echo
done < $1

#TASK FINISHED INDICATION

echo
echo Task Finished.
echo `/bin/date`

Re: Change all connected IP sets mode to Alcatel Dynamic

Posted: 10 Mar 2016 09:54
by sadim
You can replace your iptouch_dhcp.sh file by the one in attach
iptouch_dhcp.zip

Re: Change all connected IP sets mode to Alcatel Dynamic

Posted: 10 Mar 2016 12:08
by Maulwurf
Hi sadim,

thank you very much for helping me. That is great.
With your new "iptouch_dhcp.sh" it works in my lab. I see you added... LINE="${LINE//[[:space:]]/}"
Can you explain why i need this? I will understand it. Original file from BPWS knowledge center should work with OXE R 10 and R11.
Find file and description at BPWS knowledge center. Search "000013045"

Re: Change all connected IP sets mode to Alcatel Dynamic

Posted: 10 Mar 2016 12:19
by sadim
Hello,

I added that in order to remove the spaces of on each entry of the file listipt and with this small change i did not need to change the rest of the script (except the line: eval `echo $LINE|awk -F "|" '{print "IP="$7}'` that i also had to change to eval `echo $LINE|awk -F "|" '{print "IP="$8}'`)

Regards

Re: Change all connected IP sets mode to Alcatel Dynamic

Posted: 11 Mar 2016 00:59
by tgn
good inspirarion for some other scripts. didn't found this script before on bwps.

thanks for share

regards...