I need to run Unix commands from a C++ program.
string command;
do{
cout<<"~ "<<get_current_dir_name ()<<">";
cin>>command;
if(command=="exit"||cin.eof()){
cout<<"exit!"<<endl;
system("exit");
break;
}
system(command.c_str());
}while (true);
But I get a "Permission denied" error when I use invoke the cd command (to change the current directory).
Can I use a chmod in my code? If yes, how can I use it.
I'm not able use chmod after compilation.
This is how I compile my code:
g++ -o shell *.cpp -std=c++11 -Wall -Wno-vla -pedantic -march=core2 -Os -pipe -fstack-protector-all -g3 -Wl,-O,1,-z,combreloc