Web Hosting Talk







View Full Version : Email from shell


FrozenWire
08-12-2004, 03:48 PM
How can I have a script when executed from shell that will email me at another address the IP, the hostname, and the user of where it was executed?

overulehost
08-13-2004, 09:55 AM
Is that possible?
I thought that might have to be a custom made script...
well search it at hotscript.com

robertson
08-13-2004, 10:14 AM
Perhaps this would help you. Use google...you might get some very good answers

http://www.experts-exchange.com/Programming/Programming_Platforms/Unix_Programming/Q_21072849.html

Try the above link

Kindest regards
krishnendu

allera
08-13-2004, 10:30 AM
I think what he's looking for is:

A user runs a script. That script send an email to him stating the user that ran it and what IP/hostname that user was connecting from.

Shouldn't be hard to do using env vars (which are shell-dependent, remember).

[edit]
Use the 'env' command to see the variables. Use 'echo $VAR' to echo the variable wanted...

adrade
08-17-2004, 02:38 AM
Try this:

#!/bin/sh

EMAIL="email@address"

HOST=`hostname`
mail -s 'Update' $EMAIL <<EOF
`host $HOST`

`printenv`
EOF