Page 1 of 1

Execute MM via SSH

Posted: Fri Nov 11, 2011 5:58 pm
by Zangetsu
Hey guys,

First, a big thanks for your hard work.

Ok now the big part.
My MM is working nicely and I'd like to run it on another computer (without screen/keyboard/mouse). Then I've tried to access it via SSH. It's launching macromicro.exe but it seems something is wrong here and I don't know how to interpret this. Is it trying to check it from the remote computer (client) or can't read it from the host (server with RoM and MM running), or whatever...
I dunno :S

Output from SSH
$ ./micromacro.exe
MicroMacro v1.02 beta 1
SolarStrike Software
http://www.solarstrike.net
Please enter the script name to run.
Type in 'exit' (without quotes) to exit.
Script>
Nice it seems to work :D
Welcome to rom bot! press END to quit¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
RoM Bot Version 3.29, Revision <UNKNOWN>¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
Press the (FIN) key to stop/pause the script.
You can resume with the (SUPPR) key.
You need to run rom first!
Did not find any crashed game clients.
11:56pm - ...micromacro_1.02/micromacro/scripts/rom/functions.lua:42: bad argument #1 to 'findPatternInProcess' ((null))


Please enter the script name to run.
Type in 'exit' (without quotes) to exit.
Script>
Or maybe not :S




I'm not asking a complete solution, but if you got any idea, I'd like to try.

Thanks!

Re: Execute MM via SSH

Posted: Fri Nov 11, 2011 10:06 pm
by rock5
Zangetsu wrote:You need to run rom first!
Did you start the game first?

Re: Execute MM via SSH

Posted: Sat Nov 12, 2011 12:06 am
by Zangetsu
Yes sir

Re: Execute MM via SSH

Posted: Sat Nov 12, 2011 12:12 am
by rock5
I'm not sure what you want to do. Do you want to access mm from another computer or do you want to run the game and mm on another computer?

Note: mm and the game need to be running on the same computer.

Re: Execute MM via SSH

Posted: Sat Nov 12, 2011 12:24 am
by Zangetsu
rock5 wrote:I'm not sure what you want to do. Do you want to access mm from another computer or do you want to run the game and mm on another computer?

Note: mm and the game need to be running on the same computer.

Ok, I'll try to explain it better.

I have a computer A which is a server:
MM is running on it
Runes of Magic is running on it
A SSH server is running on it.


From another computer or smartphone or whatever with a SSH client, I'm connecting to computer A.


I'm trying to start MM via SSH and send commands to it. Basically it's a kind of remote controlling.
The error seems to appear because MM can't find game process but I don't understand why. MM should be executed on computer A, even if I got the output via SSH from another client, right?

Thanks for helping Rock5

Re: Execute MM via SSH

Posted: Sat Nov 12, 2011 12:40 am
by rock5
I'm not too familiar with ssh but maybe mm is being run with some sort of 'remote' credentials so mm and rom can't see each other because they are using different credentials. Can you access mm if it was already running? Does it work then?

Re: Execute MM via SSH

Posted: Sat Nov 12, 2011 12:45 am
by Zangetsu
rock5 wrote:I'm not too familiar with ssh but maybe mm is being run with some sort of 'remote' credentials so mm and rom can't see each other because they are using different credentials. Can you access mm if it was already running? Does it work then?
Nope.
Maybe this is because of the remote access and the program doesn't handle that but this is weird.

I have another solution but I've to run the game from another PC. The way I thought is to just send chat whisp to the bot account and make the bot account execute commands but I dunno where and how to start. Do you have any direction to give me?

I'll try to search few hours still for SSH access; even if it seems doomed. :S

Re: Execute MM via SSH

Posted: Sat Nov 12, 2011 12:49 am
by rock5
What you need is people who have already managed remote access to step up and share how they did it. I get the impression from past discussions that there are such people.

Re: Execute MM via SSH

Posted: Sat Nov 12, 2011 12:52 am
by Zangetsu
rock5 wrote:What you need is people who have already managed remote access to step up and share how they did it. I get the impression from past discussions that there are such people.

Yeah I'll wait til someone with experience visit this post.
I'm not uber familiar with LUA, just learned it 3 days ago. But I'm familiar with SSH, I keep going this way.

Anyway thanks Rock5

Re: Execute MM via SSH

Posted: Sat Nov 12, 2011 5:10 pm
by Zangetsu
Ok, that's definitively impossible to handle it via SSH, maybe I'm missing something.

I'm working on my second solution but got some trouble with it.

Here is my code:

Code: Select all

function phpExplode(div,str)
  if (div=='') then return false end
  local pos,arr = 0,{}
  for st,sp in function() return string.find(str,div,pos,true) end do
    table.insert(arr,string.sub(str,pos,st-1)) 
    pos = sp + 1
  end
  table.insert(arr,string.sub(str,pos)) 
  return arr
end


function NotifyWhispers()
	repeat
      local time, moreToCome, name, msg = EventMonitorCheck("Whispers", "4,1")
         if time ~= nil then
			if name == "Master" then
				local ReplyTable = phpExplode('++', msg);
				--[[local ReplyCommande = ReplyTable[1]
				local ReplyTo = ReplyTable[2]
				local ReplyMessage = ReplyTable[3]]--
				
				if ReplyTable[1] == "REPLY" then
					RoMScript("SendChatMessage(ReplyTable[3], \"WHISPER\", 0, ReplyTable[2]);");
				else
				end
				
			else
				RoMScript("SendChatMessage(\"Whisp of \" ..name.. \" and he said: \" ..msg.. \"\", \"WHISPER\", 0, \"Master\");");
			end
         end
	until moreToCome ~= true
end

	EventMonitorStart("NotifyWhisperTimer", "CHAT_MSG_WHISPER");
	registerTimer("NotifyWhisperTimer", 3000, NotifyWhispers);

:arrow: Working
Someone whisp me, the bot is sending the whisp to the Master (another character)
If it's the master the author of the whisp sent to the bot, the condition is working and I can print the result in MM and I can see that output is fine.

exemple:

Code: Select all

print(ReplyTable[1]);

:arrow: Not Working
When:

Code: Select all

local ReplyTable = phpExplode('++', msg);
				--[[local ReplyCommande = ReplyTable[1]
				local ReplyTo = ReplyTable[2]
				local ReplyMessage = ReplyTable[3]]--
				
				if ReplyTable[1] == "REPLY" then
					RoMScript("SendChatMessage(ReplyTable[3], \"WHISPER\", 0, ReplyTable[2]);");
				else
				end
This isn't doing anything and I have no errors :?
The fact is with print(), I got a good output in MM console

Help is welcome!


EDIT
Oh yeah and my string is:

Code: Select all

REPLY++Someguy++Message

Re: Execute MM via SSH

Posted: Sat Nov 12, 2011 5:27 pm
by Zangetsu
Apparently, it's not "not doing anything", it's freezing MM console. I can't even hit "END" key to stop it >.>

Re: Execute MM via SSH

Posted: Sat Nov 12, 2011 5:45 pm
by Zangetsu
Ok, fixed it after some more wiki's reading :p

If you're interested this is a start:

Code: Select all

function phpExplode(div,str)
  if (div=='') then return false end
  local pos,arr = 0,{}
  for st,sp in function() return string.find(str,div,pos,true) end do
    table.insert(arr,string.sub(str,pos,st-1)) 
    pos = sp + 1
  end
  table.insert(arr,string.sub(str,pos)) 
  return arr
end


function NotifyWhispers()
   repeat
      local time, moreToCome, name, msg = EventMonitorCheck("Whispers", "4,1")
         if time ~= nil then
         if name == "Master" then
            local ReplyTable = phpExplode('++', msg);
            local ReplyCommande = ReplyTable[1]
            local ReplyTo = ReplyTable[2]
            local ReplyMessage = ReplyTable[3]
            
            if ReplyTable[1] == "REPLY" then
               macro = "SendChatMessage ( '"..ReplyMessage.."', \"WHISPER\", 0, '"..ReplyTo.."' )"
		sendMacro(macro);
            else
            end
            
         else
            RoMScript("SendChatMessage(\"Whisp of \" ..name.. \" and he said: \" ..msg.. \"\", \"WHISPER\", 0, \"Master\");");
         end
         end
   until moreToCome ~= true
end

   EventMonitorStart("NotifyWhisperTimer", "CHAT_MSG_WHISPER");
   registerTimer("NotifyWhisperTimer", 3000, NotifyWhispers);
I keep going and we'll be probably back to do something better ;)

Re: Execute MM via SSH

Posted: Tue Nov 15, 2011 5:43 am
by Germangold
I have a server running Windows Server SBS 2007 x64 and i am using remote via Teamviewer

Re: Execute MM via SSH

Posted: Tue Nov 15, 2011 9:39 am
by Zangetsu
Germangold wrote:I have a server running Windows Server SBS 2007 x64 and i am using remote via Teamviewer
Yeah, of course I've thought about this solution but what I wanted is to use it by "console" just because you can run a SSH client easily from a lot of device.