title: How to get the error or message after executing a cmdlet in perl
body: <p>I am using this command to search and get file details on a remote server</p>
  
  <pre><code>my $output=`psexec \\\\host cmd /c "dir /s d:\\folder\file`
  </code></pre>
  
  <p>if the files are present it will display all the files and its path and they are stored in <code>$output</code> if the path is not found or if the server does  not exist it returns the following on the cmd but not to <code>$output</code></p>
  
  <p><code>Starting cmd on host...ice on host...
  The system cannot find the path specified.
  cmd exited on host with error code 1.</code></p>
  
  <p>How can i get the message from the cmd or report error ,i tried <code>$!</code> doesn't return anything</p>