如何从 Cygwin 访问 Windows 二进制文件?

如何从 Cygwin 访问 Windows 二进制文件?

路径位于C:\WINDOWS\System32\OpenSSH\ssh.exe

它是 Windows 中的可执行文件

C:\>dir C:\WINDOWS\System32\OpenSSH\ssh.exe

 Directory of C:\WINDOWS\System32\OpenSSH

01/01/2019  01:33 AM           891,337 ssh.exe
               1 File(s)        891,337 bytes

C:\>C:\WINDOWS\System32\OpenSSH\ssh.exe
usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
           [-D [bind_address:]port] [-E log_file] [-e escape_char]
           [-F configfile] [-I pkcs11] [-i identity_file]
           [-J [user@]host[:port]] [-L address] [-l login_name] [-m mac_spec]
           [-O ctl_cmd] [-o option] [-p port] [-Q query_option] [-R address]
           [-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]]
           destination [command]

但是无法通过相同路径在 Cygwin 中访问。

[user@cygwin ~]$ ls -l "C:\WINDOWS\System32\OpenSSH\ssh.exe"
ls: cannot access C:\WINDOWS\System32\OpenSSH\ssh.exe: No such file or directory

更新 1

[user@cygwin ~]$ ls -l "C:\WINDOWS\System32\ipconfig.exe"
-rwxr-xr-x 2 user mkpasswd 29184 Apr 12  2018 C:\WINDOWS\System32\ipconfig.exe
[user@cygwin ~]$

[user@cygwin ~]$ ls -l "C:\WINDOWS\System32\ipconfig"
-rwxr-xr-x 2 user mkpasswd 29184 Apr 12  2018 C:\WINDOWS\System32\ipconfig
[user@cygwin ~]$

[user@cygwin ~]$ ls -l /cygdrive/c/WINDOWS/System32/ipconfig
-rwxrwx---+ 2 TrustedInstaller TrustedInstaller 29184 Apr 12  2018 /cygdrive/c/WINDOWS/System32/ipconfig
[user@cygwin ~]$

[user@cygwin ~]$ ls -l /cygdrive/c/WINDOWS/System32/ipconfig.exe
-rwxrwx---+ 2 TrustedInstaller TrustedInstaller 29184 Apr 12  2018 /cygdrive/c/WINDOWS/System32/ipconfig.exe
[user@cygwin ~]$

我能够使用 Windows () 和 Cygwin (/) 格式访问大多数 Windows 二进制文件,但以下情况除外:C:\WINDOWS\System32\OpenSSH\ssh.exe

[user@cygwin ~]$ ls -l /cygdrive/c/WINDOWS/System32/OpenSSH/ssh.exe
ls: cannot access /cygdrive/c/WINDOWS/System32/OpenSSH/ssh.exe: No such file or directory
[user@cygwin ~]$

[user@cygwin ~]$ ls -l "C:\WINDOWS\System32\OpenSSH\ssh.exe"
ls: cannot access C:\WINDOWS\System32\OpenSSH\ssh.exe: No such file or directory
[user@cygwin ~]$

更新 2

C:\>DIR /s/b C:\ssh.exe
C:\Windows\System32\OpenSSH\ssh.exe
C:\Windows\WinSxS\amd64_openssh-client-components-onecore_<RandomNumber1>_10.0.17134.1_none_<RandomNumber2>\ssh.exe

C:\>

答案1

将反斜杠 ( \) 更改为正斜杠 ( /),并将驱动器号加冒号 ( :) 替换为/cygdrive/加小写字母驅動器字母。 例如:

/cygdrive/c/WINDOWS/System32/OpenSSH/ssh.exe

相关内容