mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Apr 2005
Posts: 12
M
Pikka bird
OP Offline
Pikka bird
M
Joined: Apr 2005
Posts: 12
Hey all. I'm writing a script where I need to be able to read the output from a windows command prompt, as well as send commands to that prompt. (cmd.exe)

I've tried stdio.dll which read it, but crashed when sending. Also tried mConsole.dll which I liked very much except that it also crashes mirc.exe when I try to use it. Are there other dlls or other ways of doing this?

Any help much appreciated, thanks!
- MrBugman

Joined: Apr 2005
Posts: 12
M
Pikka bird
OP Offline
Pikka bird
M
Joined: Apr 2005
Posts: 12
I suppose another way of dealing with this would be to fix the crash error. Maybe someone knows how to avoid it.

Using Server 2003 with mIRC 6.16 I get this error when using mConsole.dll:

Event Type: Error
Event Source: Application Error
Event Category: (100)
Event ID: 1000
Date: 11/18/2005
Time: 6:36:43 PM
User: N/A
Computer: SURGEAV-SERV
Description:
Faulting application mirc.exe, version 6.1.6.0, faulting module user32.dll, version 5.2.3790.1830, fault address 0x00007eac.

frown
- MrBugman

Joined: Dec 2004
Posts: 81
N
Babel fish
Offline
Babel fish
N
Joined: Dec 2004
Posts: 81
I would be interested in knowing as well. I too have tried both dlls with no luck. I thought may be a COM approach to this. Though I don't know much about COM, lol.

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
might be talking out of a hole here, but i remember something from why back in WFWG days, that allowed you to send and recieive the output of a dos session, I think it was something to do with redirecting CON (console input and output) to a file?, i think your program then just read and wrote to that file(s). If you dont have any luck I could go search for it, but its been a long time, might have only worked when it was win9x rather than the WinnT that everyone (almost everyone) is on now.

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
I can do it with COM, but have no time to show you how at this time. When I get home tonight (that's in 9 hours) I'll see what we can come up with for you.


Gone.
Joined: Dec 2004
Posts: 81
N
Babel fish
Offline
Babel fish
N
Joined: Dec 2004
Posts: 81
I figured you would be the one smile I tried helping him out and couldn't figure it out, lol. Thanks FiberOptics.

Joined: Apr 2005
Posts: 12
M
Pikka bird
OP Offline
Pikka bird
M
Joined: Apr 2005
Posts: 12
That would be awesome cool

Also, many thanks to nycdiesel for working with me on the dlls for a few hours. smile

I'll look into the other redirect idea, thanks for that too.

- MrBugman

Joined: Apr 2005
Posts: 12
M
Pikka bird
OP Offline
Pikka bird
M
Joined: Apr 2005
Posts: 12
Quote:
might be talking out of a hole here, but i remember something from why back in WFWG days, that allowed you to send and recieive the output of a dos session, I think it was something to do with redirecting CON (console input and output) to a file?, i think your program then just read and wrote to that file(s). If you dont have any luck I could go search for it, but its been a long time, might have only worked when it was win9x rather than the WinnT that everyone (almost everyone) is on now.


http://www.glue.umd.edu/~nsw/enpm808c/dos.htm#Redirect
Reading through the redirect section this sounds promising, I'd have to play with it to see how it really works, appreciate the idea. =)

- MrBugman

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
This will initiate a command console (hidden) that will execute the command that you specified, and will signal the event "cmd" when all output from your command has been received. The output is stored in file cmd.txt. Btw, you should have just said what you wanted to do exactly (what commands are you trying to perform?), because if this was for let's say to redirect output from netstat.exe or ping.exe etc you dont' need the command prompt for that.

Code:
alias cmd {
  if (!$0) return
  var %wsh = wsh $+ $ticks 
  .comopen %wsh wscript.shell
  .comclose %wsh $com(%wsh,run,1,bstr*,% $+ comspec% /c $1- >cmd.txt,uint,0,bool,true)
  .signal cmd $1-
}
 [color:red]  [/color] 
on *:signal:cmd:{
  echo -a Finished executing command: $1-
}


The reason for the signal is that the alias /cmd will be halted until all the output is returned, so the code after the line that says .comclose (in our case signal) could be executed a few seconds after you issued /cmd, since it waits.


Gone.
Joined: Apr 2005
Posts: 12
M
Pikka bird
OP Offline
Pikka bird
M
Joined: Apr 2005
Posts: 12
I'm using this for a game server, collecting all of the connects and player messages from the prompt of the dedicated server to display them in a script. So the connection is constant, that seems to be the challenge here.

- MrBugman

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Why don't you just use sockets then to connect to the gameserver, that will make life easier. You should have said this from the start, preventing others from doing unnecessary thinking/spending time. If you want serious help, you're gonna have to stop being so vague, I still don't really know anything of what your script should do. What kind of commands do you want to execute from the command prompt, let's start with that. "collecting all of the connects and player messages..." doesn't mean anything to me.

Btw, it's in theory possible to have a constant connection to a command prompt,initiated with wscript.shell's exec method, but in practice it crashes your mirc when sending commands through it, or even when reading from it in certain occasions. Not usable.


Gone.
Joined: Apr 2005
Posts: 12
M
Pikka bird
OP Offline
Pikka bird
M
Joined: Apr 2005
Posts: 12
I'm sorry for being vague, was just trying to make it simple.

I'm running a Tribes 1 dedicated server, with several bots on the same machine local to the game server. Later I'd like to use this same method with other game types. I'd like to be able to collect all of the server output to parse it to echo into an IRC channel used by the group running these game servers.

Users in the game can send text to IRC and users in the IRC channel can send messages to users inside the game. I'd also like to display Player Connections/Disconnections, map changes, etc all shown in the command prompt of the dedicated game server.

I wasn't aware sockets could be used to send directly to the console or read from it?

- MrBugman

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Quote:
http://www.glue.umd.edu/~nsw/enpm808c/dos.htm#Redirect
Reading through the redirect section this sounds promising, I'd have to play with it to see how it really works, appreciate the idea. =)


No it wasnt that, althought if thats all you needed, Ie running a dos app and redirectiing output and input to/from files then sure use the > & < redirectors. But i think u said interactivily send commands to the dos window (and from that i assume u mean the application running in it).


What i was meaning was this
from COMMAND.COM /?

COMMAND [[drive:]path] [device] [/E:nnnnn] [/P] [/C string] [/MSG]
[drive:]path Specifies the directory containing COMMAND.COM file.
device Specifies the device to use for command input and output.

the device can be like COM1: etc, however from memory what i had done was a first load a small program that created a COM5 (i think) and then you called COMMAND.COM COM5:
The small program constantly monitored com5in.txt for things to type and output to com5out.txt. very simple and very usable. However i cant remebe4r what the program was called or if it was even COM5 might have been like a name u could specificy even. It was a small dos util (freeware) So i couldnt even say if it would work under Xp. Did a good job under WFWg and 95 from memory.

PS: I think FiberOptics might be on a better path hear to a solution.

Joined: Apr 2005
Posts: 12
M
Pikka bird
OP Offline
Pikka bird
M
Joined: Apr 2005
Posts: 12
I played with this stuff for a few more hours. The problem I'm having is that the dedicated server console always opens in a new prompt when I start the server, so anything I try to change the input/output for only changes for the prompt that I executed the server from, which is not the newly created prompt with the echoes. frown

Someone else has suggested telnet to me, and I may be getting somewhere with that, as Tribes1 has a telnet plugin I've installed.

Really have appreciated the help I've gotten. Want to appollogize to FiberOptics, my intent was to use the prompt reading for more than just game servers, so I wanted a solution that worked with anything that echoes to cmd.exe, which I now see is not the way to handle that when using mIRC scripting.

I'll post again and let you all know how telnet is going, so far I've been able to read general messages from the dedicated server, and it looks like I can edit the telnet code to return everything else I need.

- MrBugman

Joined: Jun 2003
Posts: 15
Z
Pikka bird
Offline
Pikka bird
Z
Joined: Jun 2003
Posts: 15
Just wanted to give a big "Thanks!" to you, FiberOPtics, for the script posted.
In modified form it functions excellent to essentially halt processing of a script while the called command is being run.

Specifically, I needed this because I'm launching an external batch file to create a folder (I'm going to guess I could actually do this with the shell scripting stuff as well, but that's for later investigation) - and need to check whether the folder was successfully created.

//echo -s $ticks | /run mybat.bat | /echo -s $isdir(c:\thedir\) | //echo -s $ticks
would execute in 1 go, and $isdir would return $false , as the dir would not exist yet.

//echo -s $ticks | /cmd mybat.bat | /echo -s $isdir(c:\thedir\) | //echo -s $ticks
waits at the /cmd , and $isdir returns $true (assuming the dir was actually created(!)) when it should smile

Thanks again!


__________
ZeBoxx
¯¯¯¯¯¯¯¯¯¯

Link Copied to Clipboard