note
Gilimanjaro
<p>How are people logging into the servers that the menu runs on?</p>
<p>If they're logging on using SSH, then the login.sh script should know about the SSH_CLIENT environment variable, which you could pass to your menu.pl script; login.sh would then contain:</p>
<code>
sudo /usr/local/bin/menu.pl --clientip $SSH_CLIENT
</code>
<p>The --clientip variable is just an idea, but it would be trivial to parse your command line using Getopt::Long if you choose to do it this way.</p>
<p>There is no 'standard' way to determine the ip of the current user, because that would assume that you're always using a network connection to connect. And that doesn't have to be the case, if you would for instance login using the local console.</p>
<p>You may want to have a look at the man-pages for <code>w</code>, <code>who</code> and <code>utmp</code> (though the latter merely describes the C library for utmp). <code>who -m</code> may also suit your purposes.</p>
<p>For a more perly solution, you may want to look at the User::Utmp module. This would allow you to inspect the login records from perl. If I remember correctly, sudo provides you with the SUDO_USER environment variable which would tell you what user originally logged in, and is running the login.sh script.</p>
544487
544487