예제 #1
0
 /// <summary>
 /// Execute with timeout
 /// </summary>
 /// <param name="shell"></param>
 /// <param name="commandToExecute"></param>
 /// <param name="timeout"></param>
 /// <returns></returns>
 public static Task <string> ExecuteCommandAsync(this ISecureShell shell,
                                                 string commandToExecute, TimeSpan timeout)
 {
     using (var cts = new CancellationTokenSource(timeout)) {
         return(shell.ExecuteCommandAsync(commandToExecute,
                                          cts.Token));
     }
 }
예제 #2
0
        /// <summary>
        /// Run command
        /// </summary>
        /// <param name="shell"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        private static async Task ExecuteCommandAsync(ISecureShell shell,
                                                      CliOptions options)
        {
            var str = await shell.ExecuteCommandAsync(
                options.GetValue <string>("-c", "--command"));

            PrintResult(options, str);
        }
예제 #3
0
 /// <summary>
 /// Execute with default timeout of 3 minutes
 /// </summary>
 /// <param name="shell"></param>
 /// <param name="commandToExecute"></param>
 /// <returns></returns>
 public static Task <string> ExecuteCommandAsync(this ISecureShell shell,
                                                 string commandToExecute)
 {
     return(shell.ExecuteCommandAsync(commandToExecute, TimeSpan.FromMinutes(3)));
 }
예제 #4
0
 /// <summary>
 /// Execute with timeout
 /// </summary>
 /// <param name="shell"></param>
 /// <param name="commandToExecute"></param>
 /// <param name="timeout"></param>
 /// <returns></returns>
 public static Task <string> ExecuteCommandAsync(this ISecureShell shell,
                                                 string commandToExecute, TimeSpan timeout) =>
 shell.ExecuteCommandAsync(commandToExecute,
                           new CancellationTokenSource(timeout).Token);