$ cat xx #! #you may need to add the path to your shell #set newtime as the date newtime=$(date +%y%d%h%M%S) #the optional flag is accepted after the initial arguments #shift is not used, there is a -l flag for logfilename #accounting for IP and Port, as well as the -l flag #tee is called to direct output to the screen and logfile if [ "$2" != "-l" ] then telnet $1 $2 | tee -a /var/log/$newtime fi if [ "$2" == "-l" ] then telnet $1 | tee -a /var/log/$3 fi if [ "$3" == "-l" ] then telnet $1 $2 | tee -a /var/log/$4 fi exit 0018@AH0018 /usr/escripts $ xx mail.yahoo.com 25 telnet: Unable to connect to remote host: Connection timed out Trying 69.147.112.160... 0018@AH0018 /usr/escripts $ xx mail.yahoo.com 25 -l p telnet: Unable to connect to remote host: Connection timed out Trying 69.147.112.160... telnet: Unable to connect to remote host: Connection timed out Trying 69.147.112.160... 0018@AH0018 /usr/escripts $