Sponsored Content
Full Discussion: IPv4 string->int
Top Forums Programming IPv4 string->int Post 302655821 by pludi on Wednesday 13th of June 2012 07:39:57 PM
Old 06-13-2012
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to convert a string to int

Hi, i want to read a text file whose content(single line) will be a number like 1 or 2 or 3 ..... what i want to do is to read the file and increment the content of the file, using unix scripting. Regards, Senthil Kumar Siddhan. (2 Replies)
Discussion started by: senthilk615
2 Replies

2. UNIX for Dummies Questions & Answers

int open(const char *pathname, int flags, mode_t mode) doubt...

hello everybody! I want to create a file with permissions for read, write, and execute to everybody using C, so I write this code: #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> int main(){ int fileDescriptor; fileDescriptor =... (2 Replies)
Discussion started by: csnmgeek
2 Replies

3. Shell Programming and Scripting

Compare string output to int value?

Hi, i'd like to implmeent emergency shutdown script in case our AC dies and the temperature rises too high. I can get core temperatures with: sensors | grep Core | cut -c15-16 Result is: 23 18 18 13 21 18 15 17 How can I check if any of the cores is above eg. 80 (that's C of... (2 Replies)
Discussion started by: zapp0
2 Replies

4. Programming

how to covert string into 2 diff int

i got a string E.g "12.67" how do i convert it into a int so that a= 12 b =67 any one can guide me along? (8 Replies)
Discussion started by: xiaojesus
8 Replies

5. Shell Programming and Scripting

From string to int ?

hello guys i m new to shell scripting and can't find out why this structure is not right I m guessing this happens because $LINESUM is a string . so how can i do this ? i want my script to do so many loops as the number of the lines of one custom file. #!/bin/bash echo give me path name... (5 Replies)
Discussion started by: xamxam
5 Replies

6. Programming

Handle int listen(int sockfd, int backlog) in TCP

Hi, from the manual listen(2): listen for connections on socket - Linux man page It has a parameter called backlog and it limits the maximum length of queue of pending list. If I set backlog to 128, is it means no more than 128 packets can be handled by server? If I have three... (3 Replies)
Discussion started by: sehang
3 Replies

7. Programming

How to pass int and return string in C?

hi I want to write a function which takes int as input and returns a string like this. char GetString(int iNo) { switch(iNo) { case 0: return "Zero"; break; case 1: return "One"; break; } } void main() { int i; printf("Enter... (1 Reply)
Discussion started by: atharalikhan
1 Replies

8. Shell Programming and Scripting

Bash shell script: Str(007) to int(7),increment it(8) & convert back to string(008)

Hi, I have the following requirement. There will be following text/line in a file (eg: search-build.txt) PRODUCT_VERSION="V:01.002.007.Build1234" I need to update the incremental build number (eg here 007) every time I give a build through script. I am able to search the string and get... (4 Replies)
Discussion started by: drwatson_droid
4 Replies

9. Programming

Splitting string and storing in int

I have a string containing 2 integers separated by /, for example 12/8 or 8/6 am want to store the numbers in two integers. (3 Replies)
Discussion started by: kristinu
3 Replies

10. Shell Programming and Scripting

Convert int to string in python

Hi, I have column 5 in a file which contains string like this for ex. RP11-125O5.2 SLCO1B1 CAPN1 FRMPD2 TXNL4B So I do by data = )] ValueError: invalid literal for int() with base 10: 'R' Can someday tell me how to convert this column into int successfully. Thank You in... (7 Replies)
Discussion started by: rossi
7 Replies
Paranoid::Network::IPv4(3pm)				User Contributed Perl Documentation			      Paranoid::Network::IPv4(3pm)

NAME
Paranoid::Network::IPv4 - IPv4-related functions VERSION
$Id: IPv4.pm,v 0.1 2012/05/29 21:37:44 acorliss Exp $ SYNOPSIS
use Paranoid::Network::IPv4; @net = ipv4NetConvert($netAddr); $rv = ipv4NetIntersect($net1, $net2); or use Paranoid::Network::IPv4 qw(:all); print "Valid IP address " if $netAddr =~ /^@{[ IPV4REGEX ]}$/; @net = ipv4NetConvert($netAddr); $broadcast = $net[IPV4BRDCST]; DESCRIPTION
This module contains a few convenience functions for working with IPv4 addresses. By default only the subroutines themselves are imported. Requesting :all will also import the constants as well. SUBROUTINES
/METHODS ipv4NetConvert @net = ipv4NetConvert($netAddr); This function takes an IPv4 network address in string format and converts it into an array containing the base network address, the broadcast address, and the netmask, in integer format. The network address can have the netmask in either CIDR format or dotted quads. In the case of a single IP address, the array with only have one element, that of the IP in integer format. Passing any argument to this function that is not a string representation of an IP address (including undef values) will cause this function to return an empty array. ipv4NetIntersect $rv = ipv4NetIntersect($net1, $net2); This function tests whether an IP or subnet intersects with another IP or subnet. The return value is essentially boolean, but the true value can vary to indicate which is a subset of the other: -1: destination range encompasses target range 0: both ranges do not intersect at all 1: target range encompasses destination range The function handles the same string formats as ipv4NetConvert, but will allow you to test single IPs in integer format as well. CONSTANTS
These are only imported if explicity requested or with the :all tag. MAXIPV4CIDR Simply put: 32. This is the largest CIDR notation supported in IPv4. IPV4REGEX Regular expression: qr/(?:d{1,3}.){3}d{1,3}/sm You can use this for validating IP addresses as such: $ip =~ m#^@{[ IPV4REGEX ]}$#; or to extract potential IPs from extraneous text: (@ips) = ( $string =~ m#(@{[ IPV4REGEX ]})#gsm); IPV4CIDRRGX Regular expression: qr#(@{[ IPV4REGEX ]})(?:/(d+|@{[ IPV4REGEX ]}))?#sm By default this will extract an IP or CIDR notation network address: ($net, $mask) = ( $ip =~ m#^@{[ IPV4CIDRRGX ]}$# ); In the case of a simple IP address $mask will be undefined. IPV4BASE This is the ordinal index of the base network address as returned by ipv4NetConvert. IPV4BRDCST This is the ordinal index of the broadcast address as returned by ipv4NetConvert. IPV4MASK This is the ordinal index of the network mask as returned by ipv4NetConvert. DEPENDENCIES
o Paranoid o Paranoid::Network::Socket BUGS AND LIMITATIONS
AUTHOR
Arthur Corliss (corliss@digitalmages.com) LICENSE AND COPYRIGHT
This software is licensed under the same terms as Perl, itself. Please see http://dev.perl.org/licenses/ for more information. (c) 2012, Arthur Corliss (corliss@digitalmages.com) perl v5.14.2 2012-05-29 Paranoid::Network::IPv4(3pm)
All times are GMT -4. The time now is 02:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy