title: cat multiple files over one ssh connection and get return value for each
body: <p>As said in the title, i'm trying to cat multiple files (content needs to be appended to existing files on host) over one ssh connection and get return value for each, i.e. if that cat for the particular file was successful or not. 
  Up to now, i did this for each file individually, by just repeating the following command for each and checking the return value.</p>
  
  <pre><code>cat specific_file | ssh user@host -i /root/.ssh/id_rsa "cat &gt;&gt; result/specific_file"
  </code></pre>
  
  <p>I then just checked the return value for each transfer (automatically) and thereby could determine the status for each file. My question is: is it possible to to this over one single ssh connection, but to obtain a return value for every single file ?</p>
  
  <p>Thanks in advance !</p>
  
  <p>EDIT:</p>
  
  <p><strong>(b)</strong> As you can see in the following, i generate a command for one specific file and then check the return code. The method containing this part of the program is then called for the different types o</p>
  
  <p>If the file was successfully logged, it can be removed from the client, and that further logging to the type of file is (still) allowed. If the file is exceeding its limits, this bit is unset in another part of the program.</p>
  
  <pre><code>sprintf(command,"/bin/cat /root/%s%s | /usr/bin/ssh log-bot@192.168.5.1 -i"
          " /root/.ssh/id_rsa \"/bin/cat &gt;&gt; result/%s%s\"", apmac,
          ending_str[source], apmac, ending_str[dest]);
  rc = system(command);
  
  if(rc != 0)
  {
      sprintf(buffer, "[%i] - LOG ERROR from %s to %s CODE %i ", (int)time(0),
              ending_str[source], ending_str[dest], rc);
      sprintf(filename,"%s%s%s", LOCAL, apmac, ending_str[source]);
  }
  else
  {
      sprintf(filename,"%s%s%s", LOCAL, apmac, ending_str[source]);
      remove(filename);
      sprintf(buffer, "[%i] - LOG process from %s to %s ok", (int)time(0),
              ending_str[source], ending_str[dest]);
  
      switch(source)
      {
      case PROBE_FILE:
          LOG_MASK_SET(globals-&gt;log_mask, LOG_MASK_PROB);
          break;
      case LIST_FILE:
          LOG_MASK_SET(globals-&gt;log_mask, LOG_MASK_LIST);
          break;
      case SCAN_FILE:
          LOG_MASK_SET(globals-&gt;log_mask, LOG_MASK_SCAN);
          break;
      default:
          /* Other cases not YET considered */
          break;
      }
  }
  </code></pre>
  
  <p>SECOND EDIT:</p>
  
  <p>I'm running this code on a router as a part of a program. Please note that i'm not allowed to add new libraries or non basic functions to the system. In addition, the ssh client on the system itself doesn't allow "-M" mode.</p>