Solved

Shell ?

Posted on 1998-11-17
6
325 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 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();
   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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

Want to promote your upcoming event?

Are you going to an event? Are you going to be exhibiting at a tradeshow? Talking at a conference? Using a promotional banner in your email signature ensures that your organization’s most important contacts stay in the know and can potentially spread the word about the event.

Question has a verified solution.

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

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…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
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.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

863 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

19 Experts available now in Live!

Get 1:1 Help Now