|
|
Subject:
Sending CTRL character in a Windows batch file
Category: Computers > Programming Asked by: dbcurry-ga List Price: $2.00 |
Posted:
21 Apr 2006 11:23 PDT
Expires: 21 May 2006 11:23 PDT Question ID: 721410 |
I need to send the command CTRL-G to a serial port in in a .BAT or .CMD batch file in Windows. I imagine it's something along the lines of: ECHO [something] >COM1 where [something] is equivalent to ^G or CTRL-G. What is the escape character or command that I need to use? |
|
Subject:
Re: Sending CTRL character in a Windows batch file
Answered By: aht-ga on 21 Apr 2006 23:51 PDT Rated: |
dbcurry-ga: Thanks for your question. The Ctrl-G character corresponds to the seventh character of the ASCII character set. That information doesn't do you much good, though, if you are using a Windows text editor such as Notepad to create your batch file. Notepad will not let you easily enter control characters using the standard method of holding down the Alt key, then typing zero on the number pad, then the decimal value of the ASCII character you want. This means that you need to use some other editor to accomplish what you want. While by no means the only way, perhaps the simplest was to do what you want, is to use the good ol' DOS EDIT program that is still available even in Windows XP today: 1. Open up a command prompt window by clicking on the Start button on your Taskbar, then selecting Run... , and type 'cmd' in the dialog box that appears followed by the OK button. 2. When the command prompt appears, type EDIT and hit Enter. 3. Your PC should find the EDIT program, and run it. You should eventually see the blue background familiar to those who lived and breathed MS-DOS back in the 80's. 4. You can enter special characters in EDIT by first hitting Ctrl-P, followed by the Ctrl- combo you are seeking... so to enter a Ctrl-G character, you would enter Ctrl-P Ctrl-G. I'll represent this as [Ctrl-P Ctrl-G]. 5. Using this, go ahead and type '.echo {Ctrl-P Ctrl-G] > COM1' 6. Now, either save this file to your hard drive so that you can easily open it to copy and paste the line into any other file using Notepad, or just keep writing the rest of your batch file in EDIT, and save the finished script as a .BAT file on your hard drive. I hope that this meets your needs! Regards, aht-ga Google Answers Researcher |
dbcurry-ga rated this answer: |
|
Subject:
Re: Sending CTRL character in a Windows batch file
From: mike_74-ga on 21 Apr 2006 14:40 PDT |
Have you tried ECHO ^G >prn Based on http://www.evergreen.edu/biophysics/technotes/program/batch.htm |
Subject:
Re: Sending CTRL character in a Windows batch file
From: mike_74-ga on 21 Apr 2006 14:42 PDT |
Just realized you wanted COM1, not a printer. Sorry. |
Subject:
Re: Sending CTRL character in a Windows batch file
From: dbcurry-ga on 23 Apr 2006 19:56 PDT |
Thanks aht-ga, it worked great. I have a power strip that can be reset via the serial port, as shown here: http://www.wti.com/guides/rpb115ug.htm The 2-line script I am now using to automate reseting the strip is this: MODE COM3:9600,N,8,1>NUL ECHO ^B^X^X^B^X^X9^M>COM3 Where CTRL characters are generated using the method you suggested, so instances of ^B, ^X, and ^M are replaced with symbols. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |