您好我正在尝试编写一个程序,我在其中向C stdlib提供一个bash系统调用,该调用将输出打印到文件中。目前,system()只会打印到控制台,不会被重定向到文件。
string read_command = "dd if=" + io_filesystem + "/" + filename + " of=" + output_directory + "/" +
"tmp.tmp bs=" + bs_string + " count=1";
string write_command = "dd if=" + output_directory + "/" + "tmp.tmp of=" +
io_filesystem + "/" + "tmp.tmp bs=" + bs_string + " count=1";
string system_read_command = "echo $(" + read_command + ") >>" + output_directory + "/out.log";
status = system(system_read_command.c_str());
string system_write_command = "echo $(" + write_command + ") >>" + output_directory + "/out.log";
status = system(system_write_command.c_str());
我希望将第二个命令的输出附加到文件的末尾而不覆盖第一个命令输出。