#!/bin/sh -u # $0 (no arguments) # A script that extracts the IP address of this computer. # -IAN! idallen@ncf.ca # Set standard PATH and umask: # export PATH=/bin:/usr/bin umask 022 hostname=$(hostname) echo "The computer is: $hostname" # Choose any *one* of these ways to get the IP address from the line # (or use any other way that works): # ipaddr=$(grep "$hostname" /etc/hosts | cut -f 1) ipaddr=$(grep "$hostname" /etc/hosts | awk '{print $1}') ipaddr=$(grep "$hostname" /etc/hosts | tr '\t' '\n' | head -1) echo "Address $ipaddr belongs to machine $hostname" whoami=$(whoami) echo "The person is: $whoami" date | tr a-z A-Z