From: Tom Stiller on 29 May 2010 15:22 In article <jollyroger-010BE2.12274229052010(a)news.individual.net>, Jolly Roger <jollyroger(a)pobox.com> wrote: > In article <4c01370f$0$2114$c3e8da3(a)news.astraweb.com>, > JF Mezei <jfmezei.spamnot(a)vaxination.ca> wrote: > > > If I access my server from another machine via telnet (or ssh), I would > > like to have a script automatically obtain the IP address that > > originated the telnet (or ssh) call and do certain things (such as setup > > the DISPLAY variable, and add the address to my postfix config for instance. > > > > How does one obtain the ip address from a shell script ? > > > > > > aka: if my laptop is at 10.0.0.150 and telnets to the server at > > 10.0.0.20, I want the script running on 10.0.0.20 get "10.0.0.150" into > > a shall variable that enables me to do things. > > > > Any hints on how to achieve this ? > > Here's a Perl script you can easily modify to do what you want. The > script looks at the output of the 'ifconfig' tool and reports the IP > address (and other info) for the first active network interface it > encounters. How can ifconfig yield any information about the remote computer which has connected to the computer running the script? -- Tom Stiller PGP fingerprint = 5108 DDB2 9761 EDE5 E7E3 7BDA 71ED 6496 99C0 C7CF
From: Jolly Roger on 29 May 2010 16:05 In article <tom_stiller-755C03.15221329052010(a)news.individual.net>, Tom Stiller <tom_stiller(a)yahoo.com> wrote: > In article <jollyroger-010BE2.12274229052010(a)news.individual.net>, > Jolly Roger <jollyroger(a)pobox.com> wrote: > > > In article <4c01370f$0$2114$c3e8da3(a)news.astraweb.com>, > > JF Mezei <jfmezei.spamnot(a)vaxination.ca> wrote: > > > > > If I access my server from another machine via telnet (or ssh), I would > > > like to have a script automatically obtain the IP address that > > > originated the telnet (or ssh) call and do certain things (such as setup > > > the DISPLAY variable, and add the address to my postfix config for > > > instance. > > > > > > How does one obtain the ip address from a shell script ? > > > > > > > > > aka: if my laptop is at 10.0.0.150 and telnets to the server at > > > 10.0.0.20, I want the script running on 10.0.0.20 get "10.0.0.150" into > > > a shall variable that enables me to do things. > > > > > > Any hints on how to achieve this ? > > > > Here's a Perl script you can easily modify to do what you want. The > > script looks at the output of the 'ifconfig' tool and reports the IP > > address (and other info) for the first active network interface it > > encounters. > > How can ifconfig yield any information about the remote computer which > has connected to the computer running the script? I misunderstood what he wanted. In that case, take a look at the output of /usr/bin/last. -- Send responses to the relevant news group rather than email to me. E-mail sent to this address may be devoured by my very hungry SPAM filter. Due to Google's refusal to prevent spammers from posting messages through their servers, I often ignore posts from Google Groups. Use a real news client if you want me to see your posts. JR
From: JF Mezei on 29 May 2010 17:26 Jolly Roger wrote: > Here's a Perl script you can easily modify to do what you want. The > script looks at the output of the 'ifconfig' tool Running this on the server will give me the server's fixed IP address, not the IP address being use by a user who has logged into the server. For instance for VMS, with an RSH created process: rem_node = f$trnlnm("SYS$REM_NODE") will set the symbol rem_node with the remote node's IP address.
From: VAXman- on 29 May 2010 19:14 In article <4c018679$0$13643$c3e8da3(a)news.astraweb.com>, JF Mezei <jfmezei.spamnot(a)vaxination.ca> writes: >Jolly Roger wrote: > >> Here's a Perl script you can easily modify to do what you want. The >> script looks at the output of the 'ifconfig' tool > >Running this on the server will give me the server's fixed IP address, >not the IP address being use by a user who has logged into the server. > >For instance for VMS, with an RSH created process: > >rem_node = f$trnlnm("SYS$REM_NODE") > >will set the symbol rem_node with the remote node's IP address. JF, JF, JF... % printenv | grep SSH SSH_CLIENT=192.168.2.2 54941 22 SSH_CONNECTION=192.168.2.2 54941 192.168.2.232 22 ^-rem IP----port^ ^--local IP-port SSH_TTY=/dev/ttys001 % printenv | grep REM REMOTEHOST=192.168.2.2 -- VAXman- A Bored Certified VMS Kernel Mode Hacker VAXman(at)TMESIS(dot)ORG And ever since I was a boy I never felt that I belonged Like everything they did to me Was an experiment to see How I would cope with the illusion In which direction would I jump Would I do it all the same As the actors in the game Or would I spit it back at them And not get caught up in their rules And live according to my own And not be used To find the fundamental truths It was going to take some time Thirty five summers down the line The wisdom of each passing year Seems to serve only to confuse Seems to serve only to confuse
From: JF Mezei on 29 May 2010 20:54 VAXman- @SendSpamHere.ORG wrote: > JF, JF, JF... > > % printenv | grep SSH Mr VAXman, Mr VAXman, Mr VAXman... if I get in via telnet, there aren't any SSH environment variables created. :-( Ian Gregory wrote: >If you want to do it for a telnet connection take a look at: ><http://unixwiz.net/tools/whoamip.html> Thanks. Looked promising until the text "won't work on BSD". However, OSX does have a utmpx file, it is in /var/run instead of /etc. And there appear to be the callable uinterface, so perhaps that utility could be made to run. Interestingly, if you cat the file, it lists stuff, but using nedit, it shows a file with tons of nulls and none of the session text :-) Jolly Roger wrote: >In that case, take a look at the output of /usr/bin/last. This also looks promising. Basically look at the first record produced with the current username listed and it should give you your current IP address.
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: sometimes need to restart to get Mail.app to work Next: simple photo editing |