473,225 Members | 1,429 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,225 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 1880

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
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.