Solved

One more comad-line question?

Posted on 2000-05-07
2
147 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
Comment Utility
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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now