Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Shell ?

Posted on 1998-11-17
6
Medium Priority
?
332 Views
Last Modified: 2010-04-15
hi guys,
i would like to know how to do a dos shell like the one in turbo c or borland c++.i wanna know how to save the current environment and then restore it back.I am working in borlannd c++ under dos platform.
0
Comment
Question by:girishr
6 Comments
 
LVL 3

Expert Comment

by:braveheart
ID: 1254356
This has nothing to do with C so it is the wrong topic area.

However, what you could do is pipe the output of "set" to a file  and edit the file to make a suitable batch file. This can then be executed to restore your environment.
0
 

Author Comment

by:girishr
ID: 1254357
hi braveheart,
i did not understand ur reply at all.well i am doing a program in C in which i need to do a dos shell.i hope u understand my Q right...please tell me why it has nothing to do with c (as u said)
0
 
LVL 3

Accepted Solution

by:
arnond earned 40 total points
ID: 1254358
I think I understand what you're trying to do:
do something like this:

while (1)
{
   read_command_from_stdin();
   understand_what_command_was_given_and_execute_appropriate_routine();
}

read_command_from_stdin() will read the command line (with scanf() or something like that) into a command string.
understand_what_command_was_given_and_execute_appropriate_routine() will find out which command was enetred, see if it's a known command and execute the relevant routine or function for that command.

If you need more help, just ask.
Arnon David.

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 3

Expert Comment

by:braveheart
ID: 1254359
Sorry, I misunderstood your question. I did not realise that you are trying to write a shell but thought you were having trouble using the DOS environment. After all, DOSSHELL is a specific product.
0
 
LVL 3

Expert Comment

by:arnond
ID: 1254360
as for saving the current environment, use a struct that will hold the environment inf and have a file to write all the environment info to and then you can always read from it and save changes to it.

Arnon David.
0
 
LVL 16

Expert Comment

by:heyhey_
ID: 1254361
it was long time ago, when I programmed on DOS, but as far as i remember

"i would like to know how to do a dos shell ..."
aren't you supposed to free as much memory as you can (leave only a small module in memory) and start new command proccess (execute COMMAND.COM)

"i wanna know how to save the current environment and then restore it back"
as far as i remember a proccess CAN'T change the enviroment of its father proccess. Every proccess receives a copy of the enciroment of its father proccess, manipulates it and then frees it. Are you trying to inform your father procces about changes in your own enviroment ?

  heyhey
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
Suggested Courses

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question