1

下面提到的 php 命令的 C++ equivalemt 命令是什么:

$command = shell_exec("sqlldr {$connect_string} control={$ctl_file_name} log={$log_file_name}");
4

2 回答 2

1

因此,根据您的评论,一个可行的解决方案是使用 popen(3):

#include <cstdio>
#include <iostream>
#include <string>

int main()
{
   // Set file names based on your input etc... just using dummies below
   std::string
     ctrlFileName = "file1",
     logFileName  = "file2",
     cmd = "sqlldr usr/pwd@LT45 control=" + ctrlFileName + " log=" + logFileName ;

   std::cout << "Executing Command: " << cmd << std::endl ;

   FILE* pipe = popen(cmd.c_str(), "r");

   if (pipe == NULL)
   {
     return -1;
   }

   char buffer[128];
   std::string result = "";

   while(!feof(pipe))
   {
     if(fgets(buffer, 128, pipe) != NULL)
     {
         result += buffer;
     }
  }

   std::cout << "Results: " << std::endl << result << std::endl ;

   pclose(pipe);
}
于 2013-03-01T13:37:33.640 回答
0

试试forkpty,你会得到一个文件描述符,你可以用它来从另一个伪终端读取。

于 2013-02-28T14:05:00.460 回答