Errors.aml 1.7 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <topic id="6df8e431-0da0-4fd3-9e26-3871030ab3af" revisionNumber="1">
  3. <developerOrientationDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
  4. <title>Execution errors</title>
  5. <content>
  6. When command is executed and error occured you can access to errir description by accessing <codeEntityReference>P:Renci.SshNet.SshCommand.Error</codeEntityReference> property.
  7. You can also check <codeEntityReference>P:Renci.SshNet.SshCommand.ExitStatus</codeEntityReference> which is in case of error should not be 0.
  8. <para>See examples below:</para>
  9. <codeExample>
  10. <list class="ordered">
  11. <listItem>
  12. <para>Execute invalid command and display execution error.</para>
  13. <code language="cs">
  14. using (var client = new SshClient("host", "username", "password"))
  15. {
  16. client.Connect();
  17. var cmd = client.CreateCommand(";");
  18. cmd.Execute();
  19. if (!string.IsNullOrEmpty(cmd.Error))
  20. {
  21. Console.WriteLine(cmd.Error);
  22. }
  23. client.Disconnect();
  24. }
  25. </code>
  26. </listItem>
  27. </list>
  28. </codeExample>
  29. </content>
  30. <relatedTopics>
  31. <codeEntityReference>P:Renci.SshNet.SshCommand.ExitStatus</codeEntityReference>
  32. <codeEntityReference>P:Renci.SshNet.SshCommand.Error</codeEntityReference>
  33. <codeEntityReference>T:Renci.SshNet.SshCommand</codeEntityReference>
  34. </relatedTopics>
  35. </developerOrientationDocument>
  36. </topic>