Skip to content

Instantly share code, notes, and snippets.

@tdmitch
Created March 16, 2017 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tdmitch/b35be8f86f5efee939740d225cce8686 to your computer and use it in GitHub Desktop.
Save tdmitch/b35be8f86f5efee939740d225cce8686 to your computer and use it in GitHub Desktop.
// This try/catch block will capture catastrophic failures (such as specifying the wrong path to winscp).
try
{
winscp.Start();
winscp.StandardInput.WriteLine(sessionOptionString);
winscp.StandardInput.WriteLine(connectString);
winscp.StandardInput.WriteLine(getString);
winscp.StandardInput.Close();
// Set the outStr to the output value, obfuscating the password
outStr = winscp.StandardOutput.ReadToEnd().Replace(":" + Dts.Variables["$Package::pServerUserPassword"].GetSensitiveValue().ToString() + "@", ":*******@");
// Wait for the application to exit
winscp.WaitForExit();
returnVal = winscp.ExitCode;
}
catch (Exception ex)
{
errStr = "An error occurred when attempting to execute winscp.com: " + ex.Message.Replace("'", "\"").Replace("--", " - ");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment