gpt4 book ai didi

php - 相当于 php shell_exec 的 c++

转载 作者:太空宇宙 更新时间:2023-11-04 14:09:51 25 4
gpt4 key购买 nike

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

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

最佳答案

因此,根据您的意见,一个可行的解决方案是使用 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);
}

关于php - 相当于 php shell_exec 的 c++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15136935/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com