I am trying to bulk add keys to my redis server using type filename.txt | redis-cli --pipe
. This works well and all data inserted successfully and i can see response in cmd window. but when tried with c# app then response file is always empty.
here is code snippet.
Process.Start("CMD.exe", "/K type c:\\Users\\username\\Desktop\\file.txt | redis-cli -h 192.168.100.28 --pipe >result.txt");
Edit 1
Also tried the solution provide by @Grigory Zhadko it displays the output of echo command but not the redis-cli output.
var process = new Process();
process.StartInfo.FileName = "CMD.exe";
process.StartInfo.Arguments = "/K type c:\\Users\\username\\Desktop\\file.txt | redis-cli -h 192.168.100.29 --pipe";
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.UseShellExecute = false;
process.Start();
process.StandardInput.WriteLine("echo hello");
process.StandardInput.WriteLine("exit");
string output = process.StandardOutput.ReadToEnd();
Here is output of this.
D:\Projects\projectname\bin\Debug>echo hello
hello
D:\Projects\projectname\bin\Debug>exit