开发者

How do I send a Carriage Return with Windows Netcat?

I want to type directly into the Powershell prompt too, not pipe in a text file.

Foo`r doesn't work for me. For example:

echo "RJ`r`n" | .\nc.exe -u  192.168.1.247 2639

but what I'd really lik开发者_如何转开发e to do is just

.\nc.exe -u  192.168.1.247 2639

then start typing into the prompt.


Try:

"Foo`ndoes work for me"

If you need a full CRLF sequence then:

"Foo`r`ndoes work for me"

Note that the escapes chars only work in double-quoted strings - not single quoted strings.

Update: Redirect in < is not supported in PowerShell at this time so you can only get stdin to the exe from the interactive prompt using the pipeline. Is it possible nc.exe is expecting another character (or escape char) to terminate the input? I know that console exes can receive stdin from PowerShell. If you have the C# compiler, you can see this by compiling the following source (csc echostdin.cs):

using System;
public class App
{
  public static void Main()
  {
    int ch;
    while ((ch = Console.In.Read()) != -1)
    {
      Console.Write((char)ch);
    }
  }
}

Then execute the exe:

PS> "foo`r`n" | .\echostdin.exe
foo

PS>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜