Sponsored Content
Full Discussion: ip address octet increments
Top Forums Programming ip address octet increments Post 302111539 by jim mcnamara on Wednesday 21st of March 2007 03:24:16 PM
Old 03-21-2007
There are two standard calls for this (for IPv4 address formats):
inet_addr() returns an integer
inet_ntoa() returns the dotted form

Take the dotted form, convert to integer, add one, convert back to dotted form.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Working with field increments

I have a new challenge that I need some help with. Each morning I have two files that contain working units and failed units that I join together to form file3 which is FTP to server for comparison against billing system. My problem, I would like to take joined data in file3 and add a field... (2 Replies)
Discussion started by: greengrass
2 Replies

2. UNIX and Linux Applications

Any idea on 3 Octet IP address ?

Hi All, I found my weblog contain entries like 121.23.3 Instead of four octet. I am quite confused is it possible to have 3 octet ip at all ?? Is it generating by any program and hittng the website ? Is it a subdomain ? Please tell me your understanding on it ? Thanks (4 Replies)
Discussion started by: jambesh
4 Replies

3. UNIX for Dummies Questions & Answers

Want to process file in 1000 record increments

I have a file that varies in the # of records. I want to read 1000 records, do something, read the next 1000 records, do something, going in 1000 increment chunks, and then finish up with whatever is left over at end of file. (1 Reply)
Discussion started by: Tsamp
1 Replies

4. Shell Programming and Scripting

Averaging in increments using awk & head/tail

Hi, I only have a very limited understanding and experience with writing code and I was hoping I could get some help. I have a dataset of two columns (txt format, numbers in each row separated by a tab) Eg. 1 5 2 5 3 6 4 7 5 6 6 6 7 ... (5 Replies)
Discussion started by: Emred_Skye
5 Replies

5. Shell Programming and Scripting

Increments in a loop

Hi All, I am trying to implement a for loop in a .sh file and execute it. My for loop is for i in 1, 200, 400, 600, 800, 1000, 1200,......100000 do ... .. .. done As you could see there is an increment of 200 in each for loop until it reaches 100,000 Instead of specifying all the... (8 Replies)
Discussion started by: Lucky Ali
8 Replies

6. UNIX for Dummies Questions & Answers

What is an (application/octet-stream) file?

I'm trying to learn as much about GRUB as I can and it's stages are stored in these types of files. Any info or search terms is appreciated!:wall: (5 Replies)
Discussion started by: theKbStockpiler
5 Replies

7. Shell Programming and Scripting

awk Quick Help: printing upto 3rd octet .

Hi Experts, I am trying to print $2 & the IP_address upto 3rd octet only. But unable to do so, Trying # awk '{print $2, substr($4,1,9)}' file . but not correct File: HOST= cmiHOST06 :: 10.26.107.73:/data120 /nbu/cmiHOST06/athpx07/aa1 HOST= cmiHOST05 :: 10.26.12.76:/data120... (5 Replies)
Discussion started by: rveri
5 Replies

8. Shell Programming and Scripting

Awk: Help with how to remove 4rth octet :

Experts, In one example I have seen how to get output upto 3rd octet, when there is a ":" separated with the 4rth octet. However in this example how to remove 4rth octet and to keep upto 3rd octet with regular expressions and awk sub function: I have tried with :but not working: # awk '{... (3 Replies)
Discussion started by: rveri
3 Replies

9. Programming

Celisus & fahrenheit table converter with fields + increments

no longer needed, please delete thread. (0 Replies)
Discussion started by: xtina
0 Replies

10. Shell Programming and Scripting

Bash subtract fourth octet of an IP by 1

Hello, Im looking to help out my team by automating a simple search list. The user will look for a peering ip /30. For example 192.168.1.2/30 and gets the result. Im trying to get the entered /30 and subtract the last octet by one. echo -n "Enter peering ip : "; read peeringip cat... (3 Replies)
Discussion started by: D'go
3 Replies
INET_ADDR(P)						     POSIX Programmer's Manual						      INET_ADDR(P)

NAME
inet_addr, inet_ntoa - IPv4 address manipulation SYNOPSIS
#include <arpa/inet.h> in_addr_t inet_addr(const char *cp); char *inet_ntoa(struct in_addr in); DESCRIPTION
The inet_addr() function shall convert the string pointed to by cp, in the standard IPv4 dotted decimal notation, to an integer value suit- able for use as an Internet address. The inet_ntoa() function shall convert the Internet host address specified by in to a string in the Internet standard dot notation. The inet_ntoa() function need not be reentrant. A function that is not required to be reentrant is not required to be thread-safe. All Internet addresses shall be returned in network order (bytes ordered from left to right). Values specified using IPv4 dotted decimal notation take one of the following forms: a.b.c.d When four parts are specified, each shall be interpreted as a byte of data and assigned, from left to right, to the four bytes of an Internet address. a.b.c When a three-part address is specified, the last part shall be interpreted as a 16-bit quantity and placed in the rightmost two bytes of the network address. This makes the three-part address format convenient for specifying Class B network addresses as "128.net.host" . a.b When a two-part address is supplied, the last part shall be interpreted as a 24-bit quantity and placed in the rightmost three bytes of the network address. This makes the two-part address format convenient for specifying Class A network addresses as "net.host" . a When only one part is given, the value shall be stored directly in the network address without any byte rearrangement. All numbers supplied as parts in IPv4 dotted decimal notation may be decimal, octal, or hexadecimal, as specified in the ISO C standard (that is, a leading 0x or 0X implies hexadecimal; otherwise, a leading '0' implies octal; otherwise, the number is interpreted as decimal). RETURN VALUE
Upon successful completion, inet_addr() shall return the Internet address. Otherwise, it shall return ( in_addr_t)(-1). The inet_ntoa() function shall return a pointer to the network address in Internet standard dot notation. ERRORS
No errors are defined. The following sections are informative. EXAMPLES
None. APPLICATION USAGE
The return value of inet_ntoa() may point to static data that may be overwritten by subsequent calls to inet_ntoa(). RATIONALE
None. FUTURE DIRECTIONS
None. SEE ALSO
endhostent() , endnetent() , the Base Definitions volume of IEEE Std 1003.1-2001, <arpa/inet.h> COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technol- ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html . IEEE
/The Open Group 2003 INET_ADDR(P)
All times are GMT -4. The time now is 08:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy