SageIP = "127.0.0.1" SagePort = "20000" Recorder1 = 0 Recorder2 = 0 function SageProcStat() SageGone = 0 SAGEID = FindProcess("SageTV.exe") if (SAGEID > 0) then SageGone = 0 else SageGone = 1 end end function ConnectToSage (SageSocketIP, SageSocketPort) SageStatusSocket = connect (SageSocketIP, SageSocketPort) if not SageStatusSocket then print ("Error Connecting to TCP Server...") return else print ("Connection Successful") return end end function GetDataFromSage () SageStatus = {} send (SageStatusSocket,"x") l , e = receive(SageStatusSocket) for i = 1, 24 do _, _, Key, Value = strfind (l, "(.*):%s*(.*)") if Key~= nil then Key = gsub (Key, "_", "") end if Key ~= nil then SageStatus[Key] = Value end l, e = receive(SageStatusSocket) end if e then print(e) else print ("Data Collected - No Error's") end end function CloseConnectionToSage () close (SageStatusSocket) print ("Connection Closed") end function SendSageDataToNR () end function CheckRecStatus() --Check for Recorder 1 busy if (SageStatus["recording1show"] == "") then Recorder1 = 0 else Recorder1 = 1 end --Check for Recorder 2 busy if (SageStatus["recording2show"] == "") then Recorder2 = 0 else Recorder2 = 1 end end SageProcStat() ConnectToSage (SageIP, SagePort) GetDataFromSage () CloseConnectionToSage () CheckRecStatus() --SendSageDataToNR () --print ("*****") foreach (SageStatus, print) --print ("******") print(Recorder1) print(Recorder2) print(Recorder3)