"|" pipe operator not working in command line in C++
<p>I am having a windows application interacting with DB2 database. In my application i have code to execute some DB2 commands through command line interface. I have used windowsAPI "ShellExecuteEx()" to execute those DB2 commands through command line.</p>

<p>Following is the code written to execute DB2 command through command line.</p>

<pre><code>  string command = "/c /w /i DB2 UNCATALOG NODE DB_DATABASE "&gt;&gt;" test.log | echo 
  %date% %time% &gt;&gt; test.log";
  SHELLEXECUTEINFO shellInfo;
  ZeroMemory(&amp;shellInfo, sizeof(shellInfo));
  shellInfo.cbSize = sizeof(shellInfo);
  shellInfo.fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_NOCLOSEPROCESS;
  shellInfo.lpFile = "db2cmd";
  shellInfo.lpParameters = command.c_str();
  if (ShellExecuteEx(&amp;shellInfo)) 
    { 
      WaitForSingleObject(shellInfo.hProcess, INFINITE); 
      CloseHandle(shellInfo.hProcess); 
      bStatus = true; 
    } 
    else 
    { 
           bStatus = false; 
    } 
</code></pre>

<p>The code is executed successfully , however if test.log is observered i only get result of DB2 command and not date and time. If you see the above command there is "|" pipe operator and echo command to log date and time in test.log</p>

<p>Please note that if I execute above DB2 command through separately command line i.e. not through code. I am able to view date and time log along with DB2 command result in test.log. Following is the full command which i executed through command line.
DB2CMD /c /i /w DB2 UNCATALOG NODE DB_DATABASE ">>" test.log | echo %date% %time% >> test.log</p>

<p>According to me since DB2 command is executed successfully through code, there is problem with only usage of "|" pipe operator or echo command.</p>
