0

I have a command line application called "terminal.exe" which provides a simple way to communicate with a modem port attached to the PC. Terminal Interface

To access the first device I would simply enter "1" and then I can send AT commands directly to the modem port.

Now, how would I write a batch file to launch "terminal.exe", then enter "1" into the terminal application and then send an AT command such as "at+cfun=1"?

I have attempted to do the following which seems to throw terminal.exe into an infinite loop where it keeps reloading the startup list of modems until I have to terminate the process with "ctr+c":

(echo 1 & echo at+cfun=1) | terminal

Thank you in advance!

ukie
  • 89
  • 2
  • 12
  • 1
    _I would simply enter "1" and then I can send AT commands_: `1` or `1`? If no ``, then try `echo 1at+cfun=1|terminal`. Note no `|` surrounding spaces. – JosefZ Dec 13 '14 at 16:50
  • And no `&` surrounding spaces if `` required: `(echo 1&echo at+cfun=1)|terminal` – JosefZ Dec 13 '14 at 17:04
  • Removing the spaces fixed the infinite loop, however, the second command does not go through. That is, once I'm connected to the COM Port the application stops responding. – ukie Dec 14 '14 at 06:16
  • Is there a way to add a pause before sending the second command? – ukie Dec 15 '14 at 22:03
  • Read [this answer](http://stackoverflow.com/a/1672349/3439404) – JosefZ Dec 15 '14 at 22:15
  • But how would that be incorporated with '(echo 1&echo at+cfun=1)|terminal' ? I am only guessing that a pause could fix this issue. Is it possible perhaps to access an application ones it's already running? – ukie Dec 16 '14 at 23:57
  • to insert a pause of right one second, use `(echo 1&ping 1.1.1.1 -n 1 -w 1000>nul&echo at+cfun=1)|terminal` however not sure whether the `>` redirector should be escaped as follows: `ping 1.1.1.1 -n 1 -w 3000^>nul` – JosefZ Dec 17 '14 at 07:24

0 Answers0