Starting rsync via ASP.Net

  • Thread starter Thread starter M_at
  • Start date Start date
M

M_at

I'm trying to automate file copying of websites between servers with a
web front end to allow our non-technical staff to make changes to sites
live in a safe and ordered manner.

I'm having difficulty using the System.Diagnostics.ProcessStartInfo
technique to start RSYNC

If I try to start RSYNC directly it doesn't terminate and does not
return control to the application.

If I try to start CMD and then pipe commands to it I do not receive
RSYNC's output.

Is there an alternative method that I may be able to try?

I'm using the following code in a C# code behind project:

System.Diagnostics.ProcessStartInfo psi = new
System.Diagnostics.ProcessStartInfo("d:\\cygwin\\bin\\rsync.exe");
psi.UseShellExecute = false;
psi.RedirectStandardOutput = true;
psi.RedirectStandardInput = true;
psi.RedirectStandardError = true;
psi.WorkingDirectory = @"c:\temp\";


// Start the process
System.Diagnostics.Process proc =
System.Diagnostics.Process.Start(psi);

// Attach the output for reading
System.IO.StreamReader sOut = proc.StandardOutput;

// Attach the in for writing
System.IO.StreamWriter sIn = proc.StandardInput;

// Close the process
proc.Close();

// Read the sOut to a string.
string results = sOut.ReadToEnd().Trim();

// Close the io Streams;
sIn.Close();
sOut.Close();

TextBox1.Text = results;

With this I would hope to see RSYNC's help output.
 
Just to follow up it appears that the ReadToEnd() (Or even replacing
this with a single ReadLine() statement) causes the hold up.

Not trying to receive any output seems to be fine.
 
Back
Top