Solved

One more comad-line question?

Posted on 2000-05-07
2
177 Views
Last Modified: 2010-03-05
how can I do this on the comandline?
#!/usr/bin/perl
use Socket;
($a, $b, $c, $d) = unpack('C4', gethostbyname($ARGV[0]));
print "$a.$b.$c.$d\n";
0
Comment
Question by:pucko
  • 2
2 Comments
 
LVL 2

Accepted Solution

by:
mattrope earned 100 total points
ID: 2786983
Can't you just use the -e switch?

perl -e 'use Socket; ($a, $b, $c, $d) = unpack("C4", gethostbyname("www.foo.com")); print "$a.$b.$c.$d\n";'


If this isn't what you want, maybe I'm not understanding your question properly...
0
 
LVL 2

Expert Comment

by:mattrope
ID: 2786985
By the way, you don't have to embed the name inside the command.  You can still use $ARGV[0] and then place the hostname on the command line after the execution string:

perl -e 'use Socket; ($a, $b, $c, $d) = unpack("C4", gethostbyname($ARGV[0])); print "$a.$b.$c.$d\n";' www.foo.com


Hope this is what you need...
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
perl match and sort unique result 2 141
Perl troubleshooting error. Base64 bootstrap parameter 5 72
PHP equivalent of opening a com object 5 89
perl getopt long help 34 71
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question