- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Issue obtaining the users IP
Operating System - HP-UX
1748076
Members
5330
Online
108758
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2004 03:02 AM
10-13-2004 03:02 AM
Solution
Okay, I have another plan, which stems from some work I've had to do recently.
Not sure why your backticks don't work, but the who command won't work anyway because you're not attached to a tty.
So, I got thinking about this, and you can do it with the lsof command. ( you can download lsof from http://hpux.connect.org.uk/hppd/hpux/Sysadmin/lsof-4.72/ )
Basically the theory is, you run lsof against your own process, and extract the line that says what STDIN (stream 1) is attached to. This will be an inet entry which will show the source and destination ip/ports. You can then extract these.
In your example, I'd suggest adding the following line to httpd.sh: -
IP=$(/usr/bin/getip $(/usr/local/bin/lsof -p $$ | grep -w "1u" | cut -d\> -f2 | cut -d: -f1))
You can then pass $IP to your binary as a parameter.
Perhaps first verify it's working with echo $IP >> /tmp/http.access.log and make sure that file gets filled with IP addresses as you access the service.
I used this in a wrapper script to log connections to inetd services that aren't clever enough to log connection attempts. I basically run a wrapper which writes ip address, date, service etc to a logfile, then pass through to the actual server daemon process.
Not sure why your backticks don't work, but the who command won't work anyway because you're not attached to a tty.
So, I got thinking about this, and you can do it with the lsof command. ( you can download lsof from http://hpux.connect.org.uk/hppd/hpux/Sysadmin/lsof-4.72/ )
Basically the theory is, you run lsof against your own process, and extract the line that says what STDIN (stream 1) is attached to. This will be an inet entry which will show the source and destination ip/ports. You can then extract these.
In your example, I'd suggest adding the following line to httpd.sh: -
IP=$(/usr/bin/getip $(/usr/local/bin/lsof -p $$ | grep -w "1u" | cut -d\> -f2 | cut -d: -f1))
You can then pass $IP to your binary as a parameter.
Perhaps first verify it's working with echo $IP >> /tmp/http.access.log and make sure that file gets filled with IP addresses as you access the service.
I used this in a wrapper script to log connections to inetd services that aren't clever enough to log connection attempts. I basically run a wrapper which writes ip address, date, service etc to a logfile, then pass through to the actual server daemon process.
- Tags:
- lsof
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2004 03:22 AM
10-13-2004 03:22 AM
Re: Issue obtaining the users IP
Thank You!
The lsof gave me excactly what I needed.
Thanks Again.
Jay
The lsof gave me excactly what I needed.
Thanks Again.
Jay
- « Previous
-
- 1
- 2
- Next »
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP