DOS to type commands in a proprietary java application and get feedback?

I am working on a project in which I would like to turn the lights on and off in Duke Smart Home using a high frequency chirp. The lighting system is called Clipsal Square-D, and the software that gives the user access to the lighting controls is called CGate. I was planning to do some signal processing in Matlab and then create a batch file from Matlab to interact with Cgate. Cgate is a proprietary Java application that, when run from the DOS command line, opens another window that is physically similar to the DOS command line. I have a batch file that can check if Cgate is working and if not, open it.

But what I can't figure out how to do is actually run commands in the Cgate program from a batch file and also take the answer from Cgate. An example of such a command is "noop", which should return "200 OK".

Any help would be greatly appreciated! Thank you in advance :)

(by the way, my existing batch file)

@ECHO off

goto checkIfOpen

:checkIfOpen

REM pv finds all open processes and puts it in result.txt
%SystemRoot%\pv\pv.exe
%SystemRoot%\pv\pv.exe > result.txt

REM if result has the word notepad in it then notepad is running
REM if not then it opens notepad
FIND "notepad.exe" result.txt
IF ERRORLEVEL 1 START %SystemRoot%\system32\Clipsal\C-Gate2\cgate.exe

goto end

:end

      

+2


source to share


2 answers


I don't know how to do this on Windows, but there is a program called expect on UNIX that is designed for this task. If you install Cygwin , you can use the Windows wait utility.



0


source


You call start cgate.exe

that will launch cgate.exe in a new window. First, you probably want to run cgate on the same window, which means you have to opt out start

.

Second, you can use shell redirection to pass commands to STDIN cgate

from a text file, for example:

cgate.exe < commands.txt

      



This will probably work, but it might not, depending on how cgate.exe is expected to receive its data.

If you want to have two-way communication where you send data, get a response and then send more data depending on the response, you will have to use something other than a batch file. Most scripting languages ​​(perl, python) or C or whatever can be used for this purpose.

0


source







All Articles