I am trying to receive a file through Netcat from a Linux based server (Raspberry Pi).
On the sender side (Raspberry Pi) I run a small Python script, that just packs up some files and sends them into the pipeline. This works great, and has been tested a lot.
On the receiver side (Windows 8.1 Pro), I use Netcat to turn the incoming stream into a file. If I do this by hand in cmd.exe, it works great:
nc -l -p <port> > C:\file.gz
My file arrives as planned. However when I try to automate this process on the receiver side with a C# script (.Net 4.5), the file simply doesn't arrive. My code looks like this:
public void StartListeningToNetcat()
{
Process ncProcess = new Process();
ncProcess.StartInfo.UseShellExecute = false;
ncProcess.StartInfo.CreateNoWindow = false;
ncProcess.StartInfo.RedirectStandardOutput = true;
ncProcess.StartInfo.RedirectStandardInput = true;
ncProcess.StartInfo.FileName = "cmd.exe";
ncProcess.StartInfo.Arguments = @"C:\...\nc -l -p <port> > C:\file.gz";
ncProcess.Start();
}
I am aware, that running nc through cmd.exe is a detour, but calling netcat directly like this:
ncProcess.StartInfo.FileName = "C:\...\nc.exe";
ncProcess.StartInfo.Arguments = @"-l -p <port> > C:\file.gz";
...returns the error: ">: forward host lookup failed: h_errno 11001: HOST_NOT_FOUND". Anyway, I wouldn't mind ignoring this error and going for the "inelegant" way to call cmd.exe.
Assuming that it could be a security measure by windows to not allow applications to write incoming files on my hard drive I tried turning of my firewall and using:
ncProcess.StartInfo.Verb = "runas";
with no success. Could somebody point me in the right direction?