Finding what IP address a process starts
This is what my friend sent me today, and I thought maybe one of you smart guys out there could help me and him:
I've got a script that clobbers my process...no biggie, I mofied the script to restart the process. However, sometimes (i.e. when I'm not the one babysititng it) it doesn't restart properly. I'm trying to make sure this is the absolute case and that the process isn't dying on its own (it's not supposed to). I've got trackkers in the script to track when it is run and by whom, only problem is it's typically run by a group account. How do I find out the IP of the terminal running the script? I.E., there is a whoami to find out the user ID, but I want a similar command to insert the IP so I know the actual HUMAN that ran the script since Our IP's are static.... I want : echo "Script ran at `date` by `whoami` " >>log.log to become: echo "Script ran at `date` by `whoami` from `**IP ADDRESS COMMAND`" >>log.log so it prints in the log: Script ran at 10 pm sun oct 27 2002 by johndoe from 255.255.255.255 |
Use the tty command to find out what terminal the user came in on, then you can lookup the terminal in the output of the 'w' command to find the IP.
|
Could this beused to help create a log file?
And what tty command? I did not know there was even that. |
As I understand it you have a shell script that several people may run from different PCs (IP addresses) but may be logged into the Linux box with the same account. You want to track the account name (whoami) and IP address of the PC that launched the script to ultimately start some process? Am i warm?
If I am mostly correct, here is what I described in my post above. The output of the tty command looks like this: Code:
# tty Code:
# w Code:
#!/bin/sh |
All times are GMT -5. The time now is 12:12 PM. |