Tyrrrz / CliWrap

Library for running command-line processes
MIT License
4.36k stars 268 forks source link

`telnet` command is throwing 'No such file or directory' error #228

Closed codewizard-dt closed 9 months ago

codewizard-dt commented 9 months ago

Version

v3.6.6

Platform

.NET 8 / MacOS 12.5.1

Steps to reproduce

Very simple example

var telnet = Cli.Wrap("telnet github.com 80") | Console.WriteLine;
await telnet.ExecuteAsync();

Details

I have no issue at all running telnet github.com 80 in a terminal window. I am new to CliWrap (which is GREAT by the way) so it may be user error, but I am using CliWrap for an nslookup command without issue. For some reason telnet command is throwing this error. I'm also new to .NET. Any advice would be appreciated. It may be related to running on MacOs since the error includes Win32Exception, but .NET is supposed to be cross platform.

System.ComponentModel.Win32Exception (2): An error occurred trying to start process 'telnet gmail.com 80' with working directory '/Users/dtaylor/Repositories/EmailServices8/EmailValidation'. No such file or directory

Checklist

Tyrrrz commented 9 months ago

The issue is that you did Cli.Wrap("telnet github.com 80"). The parameter to Wrap is just the executable/script path, it should not include the arguments. Do this instead:

Cli.Wrap("telnet")
   .WithArguments(["github.com", "80"])
codewizard-dt commented 9 months ago

Oh man. Wow. Duh, of course. I'm wondering if there is there a way to interact with telnet after the initial command? I've tried a few variations of output Pipes and input Pipes but can't figure it out. Any help would be much appreciated.

Tyrrrz commented 9 months ago

See #194 #191 for some ideas

codewizard-dt commented 9 months ago

Thank you for the response! I found those issues yesterday and I was able to work it out from there.