🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #3913

Re: Command.com and a message

#3913
From: Karol Gieszczykiewicz
Date: Fri, 14 Dec 1990 17:51
98 lines
3339 bytes

	Greetings. A while back I asked how to remind the user
	that the program is still running and to just type "EXIT"
	to return to it. Well, I got a lot of responses. The
	general concensus is to:

	1) Change the PROMPT variable
	2) Set a varaiable SHELL=yes and then test it when
	   entering (or reentering)
	3) Create a temporary, locked file when exiting (bit
	   dangerous :-)

	Since this is a summary, I will only post 1 example of
	each. Here's #1:

From: NA Schellenberge <naschell@sunee.uwaterloo.ca>
Subject: Re: Command.com and a message

Have you considered changing the PROMPT environment variable?
Something like this might do the trick (Turbo C source):

    #include <process.h>
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    void shell_to_DOS(void)
    {
        char *command_com=getenv("COMSPEC");
        char *old_prompt,*new_prompt,*tmp;

        tmp=getenv("PROMPT");
        old_prompt=malloc(8+strlen(tmp));
        if (old_prompt)
        {
            strcpy(old_prompt,"PROMPT=");
            strcat(old_prompt,tmp);
        }
        else
        {
            return;
        }
        new_prompt=malloc(strlen(tmp)+34);
        if (new_prompt)
        {
            strcpy(new_prompt,"PROMPT=Type EXIT to return...$_");
            strcat(new_prompt,tmp);
        }
        else
        {
            return;
        }
        putenv(new_prompt);
        spawnl(P_WAIT,command_com,NULL);
        putenv(old_prompt);
        free(old_prompt);
        free(new_prompt);
        return;
    }

The error handling needs improvement but I'm sure that you get the idea.
(By the way, I didn't have time to test this so be forewarned...)


	#2 would consist of:

(Beginning of program)

	a. get the variable SHELL using getenv()
	b. examine to see if it's equal to "yes"
	c. if it is, puts("Already running. Type EXIT to return");
	d. else go on.

		*
	[your program goes here]
		*

	e. get the variable SHELL using getenv()
	f. store it in a temporary variable (something else might
	   be using it - be on the safe side)
	g. putenv("SHELL=yes");
	h. spawnl(P_WAIT,command_com,NULL); putenv(old_prompt); 
	   free(old_prompt); free(new_prompt);


	#3 would be only done if you really want to fundge things.
	One could write a small file, make it SYSTEM, HIDDEN, and READ
	ONLY and exit. Then, when restarting, you would have to see
	if it's still there. If so, exit with a message, else
	run. But what happens if the powerline goes down or you have
	to reboot? A typical Joe or Jane will never figure out why
	the program keeps crashing. Unless, you want to make a
	documented utility that removes such a file ;-) So:
	DON'T DO THIS. 

	Thank you all for your help.

	Take care.
Technical Details
Message-ID: <70671@unix.cis.pitt.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!unix.cis.pitt.edu!kwgst

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!unix.cis.pitt.edu!kwgst
From: kwgst@unix.cis.pitt.edu (Karol Gieszczykiewicz)
Newsgroups: comp.os.msdos.programmer
Subject: Re: Command.com and a message
Summary: what I got.
Keywords: msdos, exit, etc.
Message-ID: <70671@unix.cis.pitt.edu>
Date: 14 Dec 90 17:51:02 GMT
Reply-To: kwgst@unix.cis.pitt.edu (Karol Gieszczykiewicz)
Followup-To: comp.os.msdos.programmer
Organization: undecided
Lines: 98