PDA

View Full Version : dumb question


3li773
08-27-2003, 02:44 PM
how can I put a dos command in my script like if I wanted to have the user enter something and then have this command

system.type(input);

that does not work but something along those lines

thnx

stuka
08-28-2003, 10:40 AM
The system() command will do this. It accepts a char* argument, so if you do: string cmd;
cout << "Enter command" << endl;
cin >> cmd;
system(cmd.c_str()); (along with all the proper setup for this), you should get what you want.

3li773
08-30-2003, 01:07 PM
Um... well that didn't do it. i wanted to do this.

lets say i want to make a directory. I would do this

system("mkdir DIR_NAME");

but lets say i wanted the user to be able to input the DIR_NAME how could i put the mkdir command in and then have the variable DIR_NAME.

thnx

stuka
09-02-2003, 10:54 AM
OK...simple modification: string dirname;
string cmd = "mkdir ";
cout << "Enter directory name" << endl;
cin >> dirname;
cmd += dirname;
system(cmd.c_str())

sans-hubris
09-02-2003, 11:36 PM
Make sure that you really are running from a console. If you're creating a GUI application, then you won't have a shell underneath your application that you can run commands from, and so you'll have to either start up the shell or find some other manner to do what you want done (in this case, creating a directory from user input.)

3li773
09-03-2003, 10:20 AM
thanks alot guys