Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Perl script running on the client machine

by Zitoune (Beadle)
on Dec 03, 2002 at 15:05 UTC ( [id://217235]=perlquestion: print w/replies, xml ) Need Help??

Zitoune has asked for the wisdom of the Perl Monks concerning the following question:

I don't know if it's possible...
I want to run a script on the client's machine to give me back their IP adresse.
Kind of , I call the script from where i am and it's giving me back the IP of the client machine.
Feedback will be apreciate ;-)
  • Comment on Perl script running on the client machine

Replies are listed 'Best First'.
Re: Perl script running on the client machine
by Callum (Chaplain) on Dec 03, 2002 at 15:11 UTC
    The function gethostbyname will return the address of a given hostname.

    edit1 -- fixed error
    edit2 -- unfixed error :)

Re: Perl script running on the client machine
by krujos (Curate) on Dec 03, 2002 at 15:47 UTC
    Callum's suggestion is excellent, and unless you have a good reason not to I suggest you do that rather than what I will advise.
    You could look into using ssh, rsh, or telnet and then run your script from that session. I suggest checking out Net::Telnet, Net::SSH and Net::Rsh.
    Good Luck
    Josh
Re: Perl script running on the client machine
by mce (Curate) on Dec 03, 2002 at 15:51 UTC
    Hi,
    Do I understand this correct?

    You want to connect to a machine over tcpip to print its ipaddress?
    Isn't this a chicken-and-egg situation?

    Or do you want to query it's ip configuration of all the adapters/interfaces in the machine

    I that case you can use the default MIB-II of snmp.


    ---------------------------
    Dr. Mark Ceulemans
    Senior Consultant
    IT Masters, Belgium

Re: Perl script running on the client machine
by MZSanford (Curate) on Dec 03, 2002 at 17:47 UTC
    If you have the name of a host, then you should be able to use gethostbyname() to get the IP from anywhere. If this is being used in a CGI context to track any sort of session data, check Super Search, as there have been comments before about IP's comming out of AOL and firewalls.
    from the frivolous to the serious
Re: Perl script running on the client machine
by iburrell (Chaplain) on Dec 04, 2002 at 02:04 UTC
    What problem are you trying to solve? Depending on what problem you want to solve there are different solutions. You need to consider that with masquerading and internal names, the machine may not know its external IP address and FQDN. The name or IP address its gives may not be accessible to the world.

    For example, "hostname" on my home machine gives "kraken". Not a domain name that could be looked up by anyone external. A local lookup or querying the interfaces would give "192.168.1.10". The machine has no clue what someone on the other side of the masquerading firewall would get; the IP address changes with DHCP leases.

Re: Perl script running on the client machine
by Zitoune (Beadle) on Dec 03, 2002 at 15:15 UTC
    it's a part of a package ??
      core
      perlfunc -f gethostbyname

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://217235]
Approved by krujos
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2024-04-20 03:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found