If I open Cygwin in rxvt, running wmic
does not show the expected wmic:root\cli>
prompt. If I execute C:\cygwin\bin\bash.exe
from cmd.exe
, running wmic
inside bash.exe
returns the expected prompt. Why?
I have the environment variable CYGWIN
set to ntsec tty
. I can echo "hello"
with a response and everything else seems happy. It's just when I run wmic and a few other Windows applications that have a prompt, the prompt never appears.
For wmic, try using
echo '' | wmic <query here>
, where<query here>
is your desired query.For instance, to get a Dell machine's service tag over SSH:
echo '' | wmic bios get serialnumber
.Getting interactive mode to work seems fruitless to me, but this should expose most of wmic's functionality to you.
Failed Attempts:
One alternative solution I read was to use
< /dev/null
at the end instead of anecho '' |
in the front, i.e.:wmic bios get serialnumber < /dev/null
. I am not, however, having luck with this one. (from Nabble thread)Another alternative solution I read was to attempt to set
tty
in theCYGWIN
environmental variable. That had no luck for me, either. (from a Larry Hall posting on the Cygwin mailing list, not linked due to spam prevention)It's ye olde Cygwin pty vs native console app issue. Rxvt is based on a "pseudo terminal device" (pty), which Cygwin implements using Windows pipes. Non-Cygwin apps only see the Windows pipes though, which makes some of them think that they should enter non-interactive mode without a prompt. (More specifically, the isatty() function returns false when invoked on a pipe.)
Depending on the version of Cygwin you are using, you may have to leverage the < /dev/null. I believe I am using 1.7 and I no longer must use < /dev/null on most versions of Windows (the exception is Windows 2003 R2, you still must use < /dev/null.)
Here is an example:
wmic bios (works on almost all versions of Windows) wmic bios < /dev/null (works on all versions of Windows based on my testing)
Hope this helps.
echo not required.
Run in cygnin prompt: