Sponsored Content
Top Forums Shell Programming and Scripting Need help to copy the lease info block Post 302401083 by SMNK on Friday 5th of March 2010 12:45:30 AM
Old 03-05-2010
Data Need help to copy the lease info block

Hi,

am having a lease file which contains lots os lease info. In that i have to copy the whole block(shown below) by identifying the mac and change the IP according to the i/p.

I have used like
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

above lines are in for loop

here i grep using before and after option, but now the lines in lease info may vary....
Code:
lease 172.19.134.239 {
  starts 3 2010/02/10 04:59:07;
  ends 3 2010/02/10 13:59:07;
  ----------------------
 ---------------------- (No of lines which may vary in between   
 ---------------------    automatically thro dhcpd)
 -----------------------
  binding state active;
  next binding state free;
  hardware ethernet 00:1d:45:56:b0:e2;
  uid "\000cisco-001d.4556.b0e2-Fa0.14";
  option agent.circuit-id "eth0";
  client-hostname "WAP";
}

I need a solution to copy the lease info.

Any help is appreciated!!!
Thanks in advance

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

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)					      BSD File Formats Manual						DHCLIENT.LEASES(5)

NAME
dhclient.leases -- DHCP client lease database DESCRIPTION
The Internet Software 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 lease file is named dhclient.leases.IFNAME, where IFNAME represents the network interface the DHCP client acquired the lease on. For example, if dhclient(8) is configured for the em0 network device, the lease file will be named dhclient.leases.em0. The format of the lease declarations is described in dhclient.conf(5). FILES
/var/db/dhclient.leases.IFNAME Current lease file. SEE ALSO
dhclient.conf(5), dhcp-options(5), dhcpd.conf(5), dhclient(8), dhcpd(8) RFC 2132, RFC 2131. AUTHORS
The dhclient(8) utility was written by Ted Lemon <mellon@vix.com> under a contract with Vixie Labs. The current implementation was reworked by Henning Brauer <henning@openbsd.org>. BSD
January 1, 1997 BSD
All times are GMT -4. The time now is 04:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy