Sponsored Content
Top Forums Shell Programming and Scripting Need help to copy the lease info block Post 302401095 by SMNK on Friday 5th of March 2010 01:08:53 AM
Old 03-05-2010
Code:
Input: ./xxx.sh 4 00:23:5e:04:4a:20/1/230 00:1d:45:56:b0:e2/2/239 00:19:06:eb:0a:98/3/238 00:ff:ff:ff:ff:ff/4/237

i need to copy the contents of lease info which contains the MAC am passing as input(carried out thro for loop).and have to change the IP according to the i/p given.

For ExampleSmilieconsider above input)

Iteration 1:
check for 00:23:5e:04:4a:20 which is stored in mac[0]
and consider original lease file contains IP as .237 for this MAC,

Now i have to find this mac[0] in the lease info and and update the IP as .240 according to the value passing after MAC(ie.,1 in first case)


i have sort out how to find the particular IP in case of variable number of lines between IP and MAC..


Solution Needed:

update the IP using MAC id and copy the contents of that changed lease info to some file.

i used grep option "before" and "after" to copy the lines, sed to change the IP.....case is now that lines are variable....


Code:
sed s/${ip_addr[i]}/$ch_ip/g $temp_file | grep -B5 "${mac[$i]}" >> $persistent_file
sed s/${ip_addr[i]}/$ch_ip/g $temp_file | grep -A4 "${mac[$i]}" | grep -v "${mac[$i]}" >> $persistent_file


Last edited by Scott; 03-05-2010 at 02:14 AM.. Reason: Code tags please...
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Copy and keep owner info

I need to copy all fiels and directories to another locathon and keep the owner info and rights. I tried cp -r - p * /newdir No good. (5 Replies)
Discussion started by: aarono
5 Replies

2. Shell Programming and Scripting

Need to delete duplicate lease entry

Hi *, I need to delete duplicate lease entries in file according to MAC/IP. I'm having tempfile which contains many lease info and need to have one entry for each IP(not more than that), if it contains more than one entry for same set, need to be deleted that entry... EX: lease... (4 Replies)
Discussion started by: SMNK
4 Replies

3. Shell Programming and Scripting

Need help to locate the particular line in lease block

Hi, I need a help that i want to get the IP which is located at the first line of lease block, using mac id i have to get that ip....In between IP and MAC, the number of lines may vary.....i tried using Grep before 5 line and using awk i took the IP...But the scenario am facing is that... (3 Replies)
Discussion started by: SMNK
3 Replies

4. UNIX for Advanced & Expert Users

DHCP lease under SuSE is not working. Why?

Hi, I got a strange issue here: We are using ISC DHCP v4 which is default in Open SuSE 11.4. These two options 'default-lease-time' and 'max-lease-time' are set in all subnets, with values between 43200 (12 hours) to 518400 (144 hours). See partial dhcpd.conf below please. Now the lease time... (0 Replies)
Discussion started by: aixlover
0 Replies

5. IP Networking

DHCP lease under SuSE is not working., limited at 10 minutes

Hi, I got a strange issue here: We are using ISC DHCP v4 which is default in Open SuSE 11.4. These two options 'default-lease-time' and 'max-lease-time' are set in all subnets, with values between 43200 (12 hours) to 518400 (144 hours). See partial dhcpd.conf below please. Now the lease... (5 Replies)
Discussion started by: aixlover
5 Replies

6. Shell Programming and Scripting

How to extract the day of the year and use that info to copy a file remotely

Hello, Thank you in advance for helping a newbie who is having great trouble with this simple task. I'm allowed to copy one file remotely each night due to bandwidth restrictions. A new file gets generated once a day, and I need to copy the previous day's file. Here is what I'd like to do:... (1 Reply)
Discussion started by: tmozdzen
1 Replies

7. UNIX for Dummies Questions & Answers

remove duplicate entries from dhcp.lease

Hi, I have to parse the dhcp.lease file and have to keep the most recent entry and remove the rest and also the number of lines between any two leases might not always be the same. eg: lease 5.5.5.252 { starts Wed Jul 27 09:48:39 2011 ends Wed Jul 27 21:48:39 2011 tstp Wed Jul... (1 Reply)
Discussion started by: bitspradp
1 Replies

8. Red Hat

DHCP lease problem

Hi frnds I am testing DHCP server on vmware.I have two REDHAT 9 vmware machine.DHCP is installed on one machine and second machine is using as a client .I have configured DHCP with Ip Address ,Mask and Gateway.But client machine is not getting ip address.When i type ifconfig command on client it... (6 Replies)
Discussion started by: Vaibhav.T
6 Replies

9. Solaris

Solaris 10- DHCP lease time increase

HI Admins, can anyone tell me how can I increase the lease time in Solaris 10. I want to use that dhcp address for 4 weeks. (2 Replies)
Discussion started by: snchaudhari2
2 Replies

10. Shell Programming and Scripting

Script to copy certain info from several directories

Hi, I am writing a script to copy certain file name in txt file . It is working fine if I provide a single directory name (for example "/eos/uscms/store/user/pooja04//analysis2012/525/data/doubleele/2012/datav1/" ) where those specific files are present ending with *root . But I want to modify... (14 Replies)
Discussion started by: nrjrasaxena
14 Replies
dhclient.leases(5)						File Formats Manual						dhclient.leases(5)

NAME
dhclient.leases - DHCP client lease database DESCRIPTION
The Internet Systems Consortium DHCP client keeps a persistent database of leases that it has acquired that are still valid. The database is a free-form ASCII file containing one valid declaration per lease. If more than one declaration appears for a given lease, the last one in the file is used. The file is written as a log, so this is not an unusual occurrence. The format of the lease declarations is described in dhclient.conf(5). FILES
DBDIR/dhclient.leases SEE ALSO
dhclient(8), dhcp-options(5), dhclient.conf(5), dhcpd(8), dhcpd.conf(5), RFC2132, RFC2131. AUTHOR
dhclient(8) was written by Ted Lemon under a contract with Vixie Labs. Funding for this project was provided by Internet Systems Consor- tium. Information about Internet Systems Consortium can be found at https://www.isc.org. dhclient.leases(5)
All times are GMT -4. The time now is 12:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy