Solved

Shell ?

Posted on 1998-11-17
6
324 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
Comment Utility
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
Comment Utility
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 20 total points
Comment Utility
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 3

Expert Comment

by:braveheart
Comment Utility
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
Comment Utility
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_
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
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…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files 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.

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now