473,651 Members | 3,090 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1902

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.u k
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.1asdf dasf) && "in", "valid"'
Bareword found where operator expected at -e line 1, near
"1.1.1.1asdfdas f"
(Missing operator before asdfdasf?)
syntax error at -e line 1, near "1.1.1.1asdfdas f"
Execution of -e aborted due to compilation errors.


Ben Morrow <us****@morrow. me.uk> wrote in message news:<c1******* ***@wisteria.cs v.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.cs v.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.1asdf dasf) && "in", "valid"'
Bareword found where operator expected at -e line 1, near
"1.1.1.1asdfdas f"
(Missing operator before asdfdasf?)
syntax error at -e line 1, near "1.1.1.1asdfdas f"
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.1ada d")
&& "in", "valid"'
invalid
~% perl -MValidate::Net -le'print !Validate::Net->ip("1.1.11." )
&& "in", "valid"'
invalid

or, better,

#!/bin/sh

VALID_IP=$(<<CM D
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.u k
Jul 19 '05 #5
That worked great. my bad.

Thanks

Ben Morrow <us****@morrow. me.uk> wrote in message news:<c1******* ***@wisteria.cs v.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.cs v.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.1asdf dasf) && "in", "valid"'
Bareword found where operator expected at -e line 1, near
"1.1.1.1asdfdas f"
(Missing operator before asdfdasf?)
syntax error at -e line 1, near "1.1.1.1asdfdas f"
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.1ada d")
&& "in", "valid"'
invalid
~% perl -MValidate::Net -le'print !Validate::Net->ip("1.1.11." )
&& "in", "valid"'
invalid

or, better,

#!/bin/sh

VALID_IP=$(<<CM D
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
1443
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 c:\\projects I want it to ignore -folder c:\\projects and pass that on to the script.
2
7076
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 the service can't retrieve the commandline property of the processes. I think this is an result of .NET Framework 1.1 Service Pack 1 or XP SP2. Did somebody recognice the same effect? Did anybody knows how i can retrieve the commandline property...
1
6496
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 to external dll which have different paths on each machine. I am currently writing a build script and passing the specific path to the project file via the /p: switch of msbuild. My current build line is:
0
2736
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. CBOE appears to keep your form query data in cookies, so this seemed like a good use of curl. Well, my script works just fine when run from the commandline. When accessed from my browser, it returns an empty string where the data should be....
4
1348
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 advance.
2
1651
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 usefulness of such a program lies in the filtering stage, in a possible integration with readline, or in other interface enhancements. Still, I'd like to discuss with you the unfiltered, unembellished version, because I'm not satisfied with it and...
2
2931
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 settings and javascripts, and output a clean html/xhtml. Optionally, it would be nice if this tool can take an acceptable tag list and remove all tags not in this list. I need such a tool to process a lot of static html document I am working on....
3
3471
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 from user at command line and prints number of digits...Please expalin how to compile and run in command line
2
2397
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 error "Undefined variable: argv" and hence dosent run. I know that there is some issue with PHP version. i'm running PHP 5.2.5 (cli) where as on server its 4.2.2 . So tell me what do i need to do in this case.?? Regards, RP
1
8466
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8584
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7299
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5615
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4144
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4290
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2701
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1912
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1588
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.