Fetch "my" IP address in HPUX 10.20


 
Thread Tools Search this Thread
Top Forums Programming Fetch "my" IP address in HPUX 10.20
# 1  
Old 10-04-2001
Question Fetch "my" IP address in HPUX 10.20

It sure sounds like a simple request....

I need some C code that will enable me to fetch the IP address of the tty attached to the current process.

In short:

char *myIPAddress(void)
{
// somebody help me fill in this part!!
}

-BLSmilie
# 2  
Old 10-04-2001
Um, ttys do not have ip addresses.

I think you want the foreign address where the connection originated from? That's hard. The information is in another process. You would need root authority to poke around in /dev/kmem for the answer. The freeware program lsof can do this. You can build a tool around that. HP-UX makes an attempt to record this in utmp. Another possibility is to build something around "who -R am i" (hp-ux specific).

Either way I see a shell script around lsof or who that outputs the ip address. Then you would invoke the script via popen(3) to read the result.
# 3  
Old 10-04-2001
Well....

Perhaps my use of the term 'tty' was inappropriate.

Our application is a Warehouse management system that uses a large network of wireless PC's running terminal emulators. Each wireless PC (natch) has an IP address. It would be nice to be able to capture this information for logging / debugging purposes. We are maintaining an error log table in Oracle, and we would like the client app to be able to include the IP in error messages in this table.

We can discover the IP addresses of these sessions from a host command line as follows:

who -uH am i

...and examining the "COMMENTS" column. Hence we DO know that the HPUX server has access to this information, and that the 'who' command can retrieve it. If only I had the source code for 'who' .... Smilie
# 4  
Old 10-04-2001
...or this way

Another of our developers came up with the idea of altering the shell script that runs our application, and via a combination of 'who' and 'cut' he's passing the IP address as an argument to the application.

It gets the job done, but darn it, I still think there should be a less kludgy way....
# 5  
Old 10-13-2006
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. AIX

Apache 2.4 directory cannot display "Last modified" "Size" "Description"

Hi 2 all, i have had AIX 7.2 :/# /usr/IBMAHS/bin/apachectl -v Server version: Apache/2.4.12 (Unix) Server built: May 25 2015 04:58:27 :/#:/# /usr/IBMAHS/bin/apachectl -M Loaded Modules: core_module (static) so_module (static) http_module (static) mpm_worker_module (static) ... (3 Replies)
Discussion started by: penchev
3 Replies

2. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

3. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

4. Shell Programming and Scripting

HPUX "bdf" , "%" align to right side.

Hi All, Need you help. I have HPUX “bdf” output, I need % to be align to right side. if you see there are long file systems lv so i cant do column formatting. Any idea or best way to align the "%" to be right side. /dev/emcvg02/lv01 52428800 29931 49123947 0% /abc/disco/iasbin... (7 Replies)
Discussion started by: ashanabey
7 Replies

5. HP-UX

mk_kernel : "dev_config" error (hpux 11.23)

Any clue why I'm getting the error below? I would greatly appreciate any help. HP ITRC is already engaged since this morning but until now I haven't got any resolution. I'm wondering if anybody out there got an idea on how to fix this. Thanks in advance. This is my system: HPUX11i-OE-Ent... (2 Replies)
Discussion started by: msgameng
2 Replies

6. Programming

php stop "internal row pointer" when fetch from mysql

Hi gurus, I need to call php function for fetching data from mysql but I dont want to move internal row pointer (IRP) forward. Or even get the actual IRP position then fetch data and move IRP back to remembered position. Function mysql_data_seek() is not suitable for my example because I am trying... (1 Reply)
Discussion started by: wakatana
1 Replies

7. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

8. Infrastructure Monitoring

HPUX net-SNMP interpreter "/bin/perl" not found

I am trying to install net-snmp on an HPUX box. I am getting the fallowing error message when I try to run the snmpconf file. I installed the fallowing version of net-snmp net-snmp-5.0.10.2-HP-UX_B.11.11_9000_800.tar and my HPUX box is version HP-UX commnms B.11.11 U 9000/800... (2 Replies)
Discussion started by: krisarmstrong
2 Replies

9. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies
Login or Register to Ask a Question