title: execute cassandra command line from C#
body: <p>I would like to execute a cqlsh copy command from c# source code.  I would like to execute a Python script, which exists under the folowing path:</p>
  
  <pre><code>C:\Program Files\DataStax Community\python\python.exe" "C:\Program Files\DataStax Community\apache-cassandra\bin\cqlsh.py
  </code></pre>
  
  <p>That will give me this screenshot:
  <a href="https://i.stack.imgur.com/C7x7W.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/C7x7W.png" alt="enter image description here"></a></p>
  
  <p>Once in cqlsh, I can then run the command "copy emp to emp.csv"
  The idea,  is that I would like to execute all this from c# code.  Here is what I did:</p>
  
  <pre><code> try
              {
  
  Process p = new Process(); // create process (i.e., the python program
              p.StartInfo.FileName = @"C:\Python27\python.exe";
              p.StartInfo.RedirectStandardOutput = true;
              p.StartInfo.UseShellExecute = false; // make sure we can read the output from stdout
              p.StartInfo.Arguments = @"C:\Program Files\DataStax Community\apache-cassandra\bin\cqlsh.py" + " " + "-e copy key_space.emp to 'D:/emp.csv'"; // start the python program with two parameters
              p.Start(); // start the process (the python program)
              p.WaitForExit();
  
              }catch(Exception ex)
              {
                  Console.WriteLine(ex.Message);
                  string strError = ex.Message;
              } 
  </code></pre>
  
  <p>There is no exception caught  but also there is nothing happened in term of result.
  Any help would be appreciated .</p>