Shell ?

Posted on 1998-11-17
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.
Question by:girishr

Expert Comment

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.

Author Comment

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)

Accepted Solution

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

while (1)

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.

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!


Expert Comment

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.

Expert Comment

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.
LVL 16

Expert Comment

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 ?


Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
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…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

832 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