473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

commandline version of this script.

#!/usr/bin/perl
use Validate::Net;
if ( Validate::Net->ip($ARGV[0]))
{
print "valid";
exit 0;
}
print "invalid";
#--done

is it even doable?
Jul 19 '05 #1
5 1885

ne******@yahoo.com (NNTP) wrote:
#!/usr/bin/perl
use Validate::Net;
if ( Validate::Net->ip($ARGV[0]))
{
print "valid";
exit 0;
}
print "invalid";
#--done

is it even doable?


err... (untested)

perl -MValidate::Net -le'print !Validate::Net->ip(shift) && "in", "valid"'

Ben

--
"If a book is worth reading when you are six, * be*@morrow.me.uk
it is worth reading when you are sixty." - C.S.Lewis
Jul 19 '05 #2
NNTP wrote:
#!/usr/bin/perl
use Validate::Net;
if ( Validate::Net->ip($ARGV[0]))
{
print "valid";
exit 0;
}
print "invalid";
#--done

is it even doable?


Worked for me. Here is the script i used:

#!/usr/bin/perl -w

use strict;
use Validate::Net;

if (Validate::Net->ip($ARGV[0])) {
print "valid\n";
exit 0;
}
print "invalid\n";

Jul 19 '05 #3
This script does work but what I am trying to do is call it from
another script and I don't want to have 2 scripts if I can just
replace this script with a command like Ben suggested,

perl -MValidate::Net -le'print \!Validate::Net->ip(shift) && "in",
"valid"'
doesn't work

sh-2.05a# ./validateip.pl 1.1.1.1
valid
sh-2.05a# ./validateip.pl 1.1.1.1asdfdasf
invalid
sh-2.05a# cat validateip.pl
#!/usr/bin/perl
use Validate::Net;
if ( Validate::Net->ip($ARGV[0]))
{
print "valid
";
exit 0;
}
print "invalid
";
sh-2.05a# perl -MValidate::Net -le'print \!Validate::Net->ip(1.1.1.1)
&& "in", "valid"'
invalid
sh-2.05a# perl -MValidate::Net -le'print \!Validate::Net->ip(1.1.11.)
&& "in", "valid"'
syntax error at -e line 1, near ".) "
Execution of -e aborted due to compilation errors.
sh-2.05a# perl -MValidate::Net -le'print
\!Validate::Net->ip(1.1.1.1asdfdasf) && "in", "valid"'
Bareword found where operator expected at -e line 1, near
"1.1.1.1asdfdasf"
(Missing operator before asdfdasf?)
syntax error at -e line 1, near "1.1.1.1asdfdasf"
Execution of -e aborted due to compilation errors.


Ben Morrow <us****@morrow.me.uk> wrote in message news:<c1**********@wisteria.csv.warwick.ac.uk>...
ne******@yahoo.com (NNTP) wrote:
#!/usr/bin/perl
use Validate::Net;
if ( Validate::Net->ip($ARGV[0]))
{
print "valid";
exit 0;
}
print "invalid";
#--done

is it even doable?


err... (untested)

perl -MValidate::Net -le'print !Validate::Net->ip(shift) && "in", "valid"'

Ben

Jul 19 '05 #4
[don't top-post]
[wrap your posts at 72 chars or so]

ne******@yahoo.com (NNTP) wrote:
Ben Morrow <us****@morrow.me.uk> wrote in message
news:<c1**********@wisteria.csv.warwick.ac.uk>...
ne******@yahoo.com (NNTP) wrote:

#!/usr/bin/perl
use Validate::Net;
if ( Validate::Net->ip($ARGV[0]))
{
print "valid";
exit 0;
}
print "invalid";
#--done

is it even doable?


err... (untested)

perl -MValidate::Net -le'print !Validate::Net->ip(shift) && "in", "valid"'


perl -MValidate::Net -le'print \!Validate::Net->ip(shift) && "in",
"valid"'
doesn't work

sh-2.05a# perl -MValidate::Net -le'print \!Validate::Net->ip(1.1.1.1)
&& "in", "valid"'
invalid
sh-2.05a# perl -MValidate::Net -le'print \!Validate::Net->ip(1.1.11.)
&& "in", "valid"'
syntax error at -e line 1, near ".) "
Execution of -e aborted due to compilation errors.
sh-2.05a# perl -MValidate::Net -le'print
\!Validate::Net->ip(1.1.1.1asdfdasf) && "in", "valid"'
Bareword found where operator expected at -e line 1, near
"1.1.1.1asdfdasf"
(Missing operator before asdfdasf?)
syntax error at -e line 1, near "1.1.1.1asdfdasf"
Execution of -e aborted due to compilation errors.


Try using it right:

~% perl -MValidate::Net -le'print !Validate::Net->ip("1.1.1.1")
&& "in", "valid"'
valid
~% perl -MValidate::Net -le'print !Validate::Net->ip("1.1.1.1adad")
&& "in", "valid"'
invalid
~% perl -MValidate::Net -le'print !Validate::Net->ip("1.1.11.")
&& "in", "valid"'
invalid

or, better,

#!/bin/sh

VALID_IP=$(<<CMD
perl -MValidate::Net -le'print !Validate::Net->ip(shift) && "in", "valid"'
CMD
)

eval $VALID_IP 1.1.1.1
eval $VALID_IP 1.1.11.
eval $VALID_IP 1.1.1.1adsf

Ben

--
don't get my sympathy hanging out the 15th floor. you've changed the locks 3
times, he still comes reeling though the door, and soon he'll get to you, teach
you how to get to purest hell. you do it to yourself and that's what really
hurts is you do it to yourself just you, you and noone else * be*@morrow.me.uk
Jul 19 '05 #5
That worked great. my bad.

Thanks

Ben Morrow <us****@morrow.me.uk> wrote in message news:<c1**********@wisteria.csv.warwick.ac.uk>...
[don't top-post]
[wrap your posts at 72 chars or so]

ne******@yahoo.com (NNTP) wrote:
Ben Morrow <us****@morrow.me.uk> wrote in message
news:<c1**********@wisteria.csv.warwick.ac.uk>...
ne******@yahoo.com (NNTP) wrote:
>
> #!/usr/bin/perl
> use Validate::Net;
> if ( Validate::Net->ip($ARGV[0]))
> {
> print "valid";
> exit 0;
> }
> print "invalid";
> #--done
>
> is it even doable?

err... (untested)

perl -MValidate::Net -le'print !Validate::Net->ip(shift) && "in", "valid"'


perl -MValidate::Net -le'print \!Validate::Net->ip(shift) && "in",
"valid"'
doesn't work

sh-2.05a# perl -MValidate::Net -le'print \!Validate::Net->ip(1.1.1.1)
&& "in", "valid"'
invalid
sh-2.05a# perl -MValidate::Net -le'print \!Validate::Net->ip(1.1.11.)
&& "in", "valid"'
syntax error at -e line 1, near ".) "
Execution of -e aborted due to compilation errors.
sh-2.05a# perl -MValidate::Net -le'print
\!Validate::Net->ip(1.1.1.1asdfdasf) && "in", "valid"'
Bareword found where operator expected at -e line 1, near
"1.1.1.1asdfdasf"
(Missing operator before asdfdasf?)
syntax error at -e line 1, near "1.1.1.1asdfdasf"
Execution of -e aborted due to compilation errors.


Try using it right:

~% perl -MValidate::Net -le'print !Validate::Net->ip("1.1.1.1")
&& "in", "valid"'
valid
~% perl -MValidate::Net -le'print !Validate::Net->ip("1.1.1.1adad")
&& "in", "valid"'
invalid
~% perl -MValidate::Net -le'print !Validate::Net->ip("1.1.11.")
&& "in", "valid"'
invalid

or, better,

#!/bin/sh

VALID_IP=$(<<CMD
perl -MValidate::Net -le'print !Validate::Net->ip(shift) && "in", "valid"'
CMD
)

eval $VALID_IP 1.1.1.1
eval $VALID_IP 1.1.11.
eval $VALID_IP 1.1.1.1adsf

Ben

Jul 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: bry | last post by:
How do I get idly.py to send a commandline onto the script it is running with a structure like -folder c:\projects as in c:\Python23\lib\idlelib\idle.py -r c:\python23\cline.py -folder...
2
by: Christoph Borger | last post by:
Hello! I have wrote a windows service in vb.net. This service monitors the running processes with WMI and the Win32_Process class. Till last month all seems ok. But since the begin of september...
1
by: ritesh.noronha | last post by:
Hi Group, I have a question regarding the commandline options of msbuild. I am currently using msbuild to build projects using the existing solution files. These solution files have references...
0
by: axlq | last post by:
While trying to learn the ins and outs of the php CURL library, I decided to write a php script that posts a form on the Chicago Board of Options (CBOE) web site, which returns an ASCII text file. ...
4
by: smcoe1 | last post by:
I have developped a new version of software and was wondering if their was a way to launch the uninstaller for the old software through the installer. (via commandline or something) Thanks in...
2
by: Toby | last post by:
I'm trying to write a simple commandline wrapper: a script that runs another program as a child and relays unbuffered stdin and stdout to/from the child process, possibly filtering it. The...
2
by: Zhang Weiwu | last post by:
Hello. I am looking for a commandline tool to take an html document (or html document segment, a.k.a. without beginign "<html><head>..</head><body>") and process it by removing all css style...
3
by: Ariharan | last post by:
Explain me how to compile and run a C program in commandline(Windows XP Turbo C++ Version 3.0) The program must also accept commandline arguments... Explain with example program to read a number...
2
rpnew
by: rpnew | last post by:
Hi, i'm executing PHP script from command line. It workds perfectly on my machine but gives error on server. It is showing problem with $argv variable. On my machine script runs and on server gives...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.