• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 198
  • Last Modified:

One more comad-line question?

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
pucko
Asked:
pucko
  • 2
1 Solution
 
mattropeCommented:
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
 
mattropeCommented:
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 does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now