Running a linux command in C++ program -
i trying run following in c++ program:
string cmd("strings -n 3 < binaryfile > ascii.txt"); system(cmd.c_str(); binaryfile string contains /home/test/binaryfile
when run so, following output:
sh: binaryfile: no such file or directory if try following:
string cmd("strings -n 3 < binaryfile.c_str() > ascii.txt"); system(cmd.c_str(); i these errors:
sh -c: line 0: syntax error near unexpected token '(' sh -c: line 0: 'strings -n 3 < binaryfile.c_str() > ascii.txt how can run properly?
you need construct command line explicitly:
string cmd("strings -n 3 < " + binaryfile + " > ascii.txt"); system(cmd.c_str()); 
Comments
Post a Comment