Index: scripts/usr/local/lib/7dtd/monitor-log.sh
===================================================================
--- scripts/usr/local/lib/7dtd/monitor-log.sh	(revision 72)
+++ scripts/usr/local/lib/7dtd/monitor-log.sh	(revision 87)
@@ -12,4 +12,5 @@
 LOG=$(getInstancePath $INSTANCE)/logs/$(date '+%Y-%m-%d_%H-%M-%S')_output.log
 CHATLOG=$(getInstancePath $INSTANCE)/logs/$(date '+%Y-%m-%d_%H-%M-%S')_chat.log
+COMMANDLOG=$(getInstancePath $INSTANCE)/logs/$(date '+%Y-%m-%d_%H-%M-%S')_commandExecution.log
 
 timestamp() {
@@ -18,25 +19,25 @@
 
 handleConnect() {
-	tel=$(telnetCommand $INSTANCE lp)
-	playerline=$(echo "$tel" | tr -d '\r' | grep "id=$2,")
-	#nickname=$(echo "$playerline" | sed -r 's/^.* id=[0-9]*, ([^,]*), pos=.*$/\1/')
-	steamid=$(echo "$playerline" | sed -r 's/^.*, health=[0-9]*, ([0-9]*)$/\1/')
+	local clientId="$1"
+	local entityId="$2"
+	local name="$3"
+	local steamId="$4"
+	local ip="$5"
 	
-	if [ -z "$steamid" ]; then
-		return
-	fi
-
-	logPlayerConnect $INSTANCE "$2" "$steamid" "$3"
+	logPlayerConnect $INSTANCE "$entityId" "$name" "$steamId" "$ip"
 
 	for H in $(getHooksFor playerConnect); do
-		$H $INSTANCE "$1" "$2" "$3" "$steamid"
+		$H $INSTANCE "$clientId" "$entityId" "$name" "$steamId" "$ip"
 	done
 }
 
 handleDisconnect() {
-	logPlayerDisconnect $INSTANCE "$2"
+	local clientId="$1"
+	local entityId="$2"
+
+	logPlayerDisconnect $INSTANCE "$entityId"
 
 	for H in $(getHooksFor playerDisconnect); do
-		$H $INSTANCE "$1" "$2" "$NICKNAME" "$STEAMID"
+		$H $INSTANCE "$clientId" "$entityId" "$NICKNAME" "$STEAMID"
 	done
 }
@@ -50,4 +51,27 @@
 }
 
+handleRemoteCommand() {
+	local cmd="$1"
+	local name="$2"
+	
+	echo "$(timestamp): Player \"$name\" executed \"$cmd\"" >> $COMMANDLOG
+
+	for H in $(getHooksFor remoteCommand); do
+		$H $INSTANCE "$cmd" "$name"
+	done
+}
+
+handleTelnetCommand() {
+	local cmd="$1"
+	local ip="$2"
+
+	echo "$(timestamp): Telnet from \"$ip\" executed \"$cmd\"" >> $COMMANDLOG
+
+	for H in $(getHooksFor telnetCommand); do
+		$H $INSTANCE "$cmd" "$ip"
+	done
+}
+
+
 if [ ! -d "$(getInstancePath $INSTANCE)/logs" ]; then
 	mkdir "$(getInstancePath $INSTANCE)/logs"
@@ -60,4 +84,11 @@
 echo "Starting instance $INSTANCE at $(timestamp)" >> $LOG
 echo >> $LOG
+
+rm $(getInstancePath $INSTANCE)/logs/current_output.log
+rm $(getInstancePath $INSTANCE)/logs/current_chat.log
+rm $(getInstancePath $INSTANCE)/logs/current_commandExecution.log
+ln -s $LOG $(getInstancePath $INSTANCE)/logs/current_output.log
+ln -s $CHATLOG $(getInstancePath $INSTANCE)/logs/current_chat.log
+ln -s $COMMANDLOG $(getInstancePath $INSTANCE)/logs/current_commandExecution.log
 
 sleep 5
@@ -73,13 +104,16 @@
 	if [ -n "$line" ]; then
 		echo "$(timestamp): $line" >> $LOG
-		if [ -n "$(echo "$line" | grep '^RequestToSpawnPlayer:')" ]; then
-			entityId=$(expr "$line" : 'RequestToSpawnPlayer: \([0-9]*\), [0-9]*, .*, [0-9]*$')
-			playerId=$(expr "$line" : 'RequestToSpawnPlayer: [0-9]*, \([0-9]*\), .*, [0-9]*$')
-			playerName=$(expr "$line" : 'RequestToSpawnPlayer: [0-9]*, [0-9]*, \(.*\), [0-9]*$')
-			unknown=$(expr "$line" : 'RequestToSpawnPlayer: [0-9]*, [0-9]*, .*, \([0-9]*\)$')
+		#Player connected, clientid=[0-9]*, entityid=[0-9]*, name=.*, steamid=[0-9]*, ip=[0-9.]*$
+		if [ -n "$(echo "$line" | grep '^Player connected,')" ]; then
+			clientId=$(expr "$line" : 'Player connected, clientid=\([0-9]*\), entityid=[0-9]*, name=.*, steamid=[0-9]*, ip=[0-9.]*$')
+			entityId=$(expr "$line" : 'Player connected, clientid=[0-9]*, entityid=\([0-9]*\), name=.*, steamid=[0-9]*, ip=[0-9.]*$')
+			playerName=$(expr "$line" : 'Player connected, clientid=[0-9]*, entityid=[0-9]*, name=\(.*\), steamid=[0-9]*, ip=[0-9.]*$')
+			steamId=$(expr "$line" : 'Player connected, clientid=[0-9]*, entityid=[0-9]*, name=.*, steamid=\([0-9]*\), ip=[0-9.]*$')
+			ip=$(expr "$line" : 'Player connected, clientid=[0-9]*, entityid=[0-9]*, name=.*, steamid=[0-9]*, ip=\([0-9.]*\)$')
 			sleep 1
-			handleConnect "$playerId" "$entityId" "$playerName"
-			unset entityId playerId playerName unknown
+			handleConnect "$clientId" "$entityId" "$playerName" "$steamId" "$ip"
+			unset clientId entityId playerName steamId ip
 		else
+		#Removing player with id clientId=[0-9]*, entityId=[0-9]*$
 		if [ -n "$(echo "$line" | grep '^Removing player with id ')" ]; then
 			playerId=$(expr "$line" : 'Removing player with id clientId=\([0-9]*\), entityId=[0-9]*$')
@@ -88,8 +122,25 @@
 			unset playerId entityId
 		else
+		#GMSG: .*$
 		if [ -n "$(echo "$line" | grep -E '^GMSG: .+')" ]; then
 			msg=$(expr "$line" : 'GMSG: \(.*\)$')
 			handleChat "$msg"
 			unset msg
+		else
+		#Executed command ".*" from player ".*"$
+		if [ -n "$(echo "$line" | grep '^Executed command ')" ]; then
+			cmd=$(expr "$line" : 'Executed command "\(.*\)" from player ".*"$')
+			nick=$(expr "$line" : 'Executed command ".*" from player "\(.*\)"$')
+			handleRemoteCommand "$cmd" "$nick"
+			unset cmd nick
+		else
+		#Telnet executed ".*" from: .*$
+		if [ -n "$(echo "$line" | grep '^Telnet executed ')" ]; then
+			cmd=$(expr "$line" : 'Telnet executed "\(.*\)" from: .*$')
+			ip=$(expr "$line" : 'Telnet executed ".*" from: \(.*\)$')
+			handleTelnetCommand "$cmd" "$ip"
+			unset cmd ip
+		fi
+		fi
 		fi
 		fi
