Thanks for the tips Alloc, I got it working

But I have another question: Is it possible to chain the telnet commands together?
Code:
EG: telnetCommand $1 "sayplayer player \"message1\""; "sayplayer player \"message 2\""; etc...
To avoid spamming the telnet connection for consecutive 'say commands'.
For anyone else that wants to use it, it displays welcome message, users playtime, days until next 7 day horde. It goes into the 'playerConnect' hooks folder. It uses PM to avoid global spam.
Code:
#!/bin/bash
. /usr/local/lib/7dtd/common.sh
###Strindex - http://stackoverflow.com/questions/5031764
strindex() {
x="${1%%$2*}"
[[ $x = $1 ]] && echo -1 || echo ${#x}
}
###Get current day###
#get telent 'gt' response
sGT="$(telnetCommand $1 "gt")"
#extract day string
sData=$(echo "$sGT" | egrep -o '^Day [0-9]{1,}')
#divide by 7, get remainder
iDay=$( expr ${sData:4} % 7)
#build seven day message
sSDMsg="There are [00FF00]$iDay days[-] until next 7day horde."
###Get player details###
sOut="$(telnetCommand $1 "lkp $3")"
#Find the desired string beginning
iPlNmStrt=$(strindex "$sOut" "1. $3,")
#Find the desired string end.
iPlNmEnd=$(strindex "$sOut" "Total of ")
#Calculate length
iOutStrLen=$(expr $iPlNmEnd - $iPlNmStrt)
#Grab the string.
sLKPStr="${sOut:$iPlNmStrt:$iOutStrLen-2}"
###Get string parts into array
OIFS=$IFS; #store existing sep
IFS="," #Change the separator to comma
aLkpArr=($sLKPStr) #serialise
IFS=$OIFS #return to default sep
###Playtime.
vPlTme="${aLkpArr[5]}"
sPlTme="${vPlTme:10:-2}"
###Build mesages
sMsg1="Welcome [00FF00]$3[-]!"
sMsg2="Playtime: [00FF00]$sPlTme mins[-]"
sMsg4="7 Nights 2 Live is an EU based PVE server. \
No Player killing or Griefing is allowed. \
Server Map: [FFFF00]http://7n2l.com[-]"
###Send messages
telnetCommand $1 "sayplayer $3 \"$sMsg1\""
telnetCommand $1 "sayplayer $3 \"$sMsg2\""
telnetCommand $1 "sayplayer $3 \"$sSDMsg\""
telnetCommand $1 "sayplayer $3 \"$sMsg4\""
- - - Updated - - -
What setup do you have? Can you add a cron job? How do you start your server normally?
Need to know setup before can give advice.