Board index » cppbuilder » system command for turbo c

system command for turbo c


2005-08-30 05:00:01 PM
cppbuilder14
Hi, i plan to write a program which will using the system("") command and as i now that it only will pass back the control when the program call by system("") command is terminate. can i call the system("") by modeless? Any solution or workaround for that?
hope you all experts share with me.
Thanks
Daron
 
 

Re:system command for turbo c

DOS does not have multitasking. Only one normal program can be active at a
time.
A program that starts another program with system or one of the spawn*
functions gives up control until the other program has finished.
There are programs that can run in the background like Terminate and Stay
Resident, TSR, programs and device drivers but they are specialized items
that are installed and not the kind of programs one executes with a call to
system.
. Ed
Quote
daron wrote in message
news:43142011$ XXXX@XXXXX.COM ...

Hi, i plan to write a program which will using the system("")
command and as i now that it only will pass back the control
when the program call by system("") command is terminate.
can i call the system("") by modeless? Any solution or
workaround for that?

hope you all experts share with me.
 

Re:system command for turbo c

Hi Ed,
I am using the DRDOS which support multitasking. I did try the spawn* before but it gave me the error "Path not found". Look like it always check for existence of the program i called. The program i called is a system program it only run on command prompt. So, i force to use system("") command.
Any idea to help me out?
Regards,
Daron
"Ed Mulroy" < XXXX@XXXXX.COM >wrote:
Quote
DOS does not have multitasking. Only one normal program can be active at a
time.

A program that starts another program with system or one of the spawn*
functions gives up control until the other program has finished.

There are programs that can run in the background like Terminate and Stay
Resident, TSR, programs and device drivers but they are specialized items
that are installed and not the kind of programs one executes with a call to
system.

. Ed

>daron wrote in message
>news:43142011$ XXXX@XXXXX.COM ...
>
>Hi, i plan to write a program which will using the system("")
>command and as i now that it only will pass back the control
>when the program call by system("") command is terminate.
>can i call the system("") by modeless? Any solution or
>workaround for that?
>
>hope you all experts share with me.


 

{smallsort}

Re:system command for turbo c

Your description suggests that what you tried to execute was not a program
at all but rather a script for the command interpreter.
When you give something like
DIR *.exe
on the command line, the command interpreter decides what to do. There is
no program called DIR.COM or DIR.EXE.
The exec* and spawn* functions execute a program. The system command
executes the command interpreter, giving it the command line that is the
calling argument.
The environment variable COMSPEC contains the name and path of the command
interpreter. Examples of its value might be
c:\command.com
c:\winnt\cmd.com
c:\windows\command.com
So when you do
system("dir *.exe");
it spawns something like this:
command /C dir *.exe
. Ed
Quote
Daron wrote in message
news: XXXX@XXXXX.COM ...

Hi Ed,
I am using the DRDOS which support multitasking. I did
try the spawn* before but it gave me the error "Path not
found". Look like it always check for existence of the program
i called. The program i called is a system program it only run
on command prompt. So, i force to use system("") command.

Any idea to help me out?
 

Re:system command for turbo c

I try to use the spawn to call the script, but it also return the error for me.
spawnl(P_WAIT, "command", " /c dir *.exe", "arg1,"arg2",NULL)
I think I need to use the script rather than a program in this post. Why i call it as a program is the DRDOS multitasking windos is a tester OS for semiconductor. So, the vendor built their program under the system.
I try to automate the user input for the program i called. the script i try to call is spawnl(P_WAIT,"FETDIF11",NULL) it return the error for me cause FETDIF11 is consider a script which only can run through command prompt.
Regards,
Daron
"Ed Mulroy" < XXXX@XXXXX.COM >wrote:
Quote
Your description suggests that what you tried to execute was not a program
at all but rather a script for the command interpreter.

When you give something like
DIR *.exe
on the command line, the command interpreter decides what to do. There is
no program called DIR.COM or DIR.EXE.

The exec* and spawn* functions execute a program. The system command
executes the command interpreter, giving it the command line that is the
calling argument.

The environment variable COMSPEC contains the name and path of the command
interpreter. Examples of its value might be
c:\command.com
c:\winnt\cmd.com
c:\windows\command.com

So when you do
system("dir *.exe");
it spawns something like this:
command /C dir *.exe

. Ed

 

Re:system command for turbo c

I do not think you are doing it correctly. Look at this example, given as a
screen capture. The paths are explicitly given in the commands is because I
have not set and configured as appropriate for TC 2.01. You should not need
to specify them.
If DRDOS works correctly for you then good. However, back when DOS had not
yet become obsolete, DRDOS always suffered from problems due to bugs which
were side effects induced by the various added "enhancements". If this does
not work on your machine then it is more likely to be a situation in which
DRDOS is not compatible with DOS even 'though it is said by the developers
to be compatible.
====================================
C:\Documents and Settings\Edward\My Documents\Lookat\q020
Quote
ver
Microsoft Windows XP [Version 5.1.2600]
C:\Documents and Settings\Edward\My Documents\Lookat\q020
Quote
type ques020.c
#include <stdio.h>
#include <stdlib.h>
#include <process.h>
int main()
{
char *comspec = getenv("COMSPEC");
printf("------------\n");
spawnl(
P_WAIT,
comspec,
comspec, /* argv[0] is the program name */
"/C", /* option telling command interpreter to not stay resident */
"dir c:\\tc\\*.*",
NULL
);
printf("------------\n");
return 0;
}
Quote
C:\Documents and Settings\Edward\My Documents\Lookat\q020
make
MAKE Version 5.2 Copyright (c) 1987, 2000 Borland
c:\tc\tcc -c -ms -Ic:\tc\include c:ques020.c
Turbo C Version 2.01 Copyright (c) 1987, 1988 Borland International
c:ques020.c:
Available memory 385342
c:\tc\tlink /x/c c:\tc\lib\c0s ques020,ques020,,c:\tc\lib\emu
c:\tc\lib\
cs
Turbo Link Version 2.0 Copyright (c) 1987, 1988 Borland International
C:\Documents and Settings\Edward\My Documents\Lookat\q020
Quote
ques020
------------
Volume in drive C has no label
Volume Serial Number is FC8D-A209
Directory of C:\TC
. <DIR>06/07/05 11:54a
.. <DIR>06/07/05 11:54a
ACCOUNTS TXT 15941 02/18/05 5:33a
ACCTS C 2466 06/08/05 4:52p
ACCTS EXE 25492 06/08/05 5:08p
ACCTS H 427 06/08/05 4:43p
ACCTS MAK 192 06/08/05 5:05p
ACCTS OBJ 3132 06/08/05 5:08p
ACCTS2 C 764 06/08/05 4:52p
ACCTS2 OBJ 1489 06/08/05 5:08p
BGI <DIR>06/08/05 11:37a
CINSTXFR EXE 18060 05/11/89 2:01a
CPP EXE 59855 05/11/89 2:01a
EXAMPLES <DIR>06/08/05 11:38a
GREP COM 7029 05/11/89 2:01a
HELPME! DOC 17971 05/11/89 2:01a
INCLUDE <DIR>06/07/05 11:54a
LIB <DIR>06/07/05 11:54a
MAKE EXE 27174 05/11/89 2:01a
OBJXREF COM 30952 05/11/89 2:01a
README 20884 05/11/89 2:01a
README COM 4201 05/11/89 2:01a
REDIR01 TXT 109 06/08/05 5:06p
SHOWIT C 359 06/08/05 5:02p
SHOWIT EXE 8980 06/08/05 5:03p
SHOWIT OBJ 520 06/08/05 5:03p
TC EXE 290525 05/11/89 2:01a
TCC EXE 180385 05/11/89 2:01a
TCCONFIG EXE 15522 05/11/89 2:01a
TCCONFIG TC 1690 06/07/05 5:32p
TCHELP TCH 219688 05/11/89 2:01a
TCINST EXE 79824 05/11/89 2:01a
THELP COM 28246 06/07/05 11:54a
THELP DOC 12682 05/11/89 2:01a
TLIB EXE 30876 05/11/89 2:01a
TLINK EXE 21717 05/11/89 2:01a
TOUCH COM 3992 05/11/89 2:01a
TURBOC CFG 30 06/07/05 11:54a
UNPACK COM 14710 05/11/89 2:01a
39 file(s) 1145884 bytes
1023932928 bytes free
------------
C:\DOCUME~1\Edward\MYDOCU~1\Lookat\q020
Quote

====================================
"daron" < XXXX@XXXXX.COM >wrote in message
Quote

I try to use the spawn to call the script, but it also return the
error for me.

spawnl(P_WAIT, "command", " /c dir *.exe", "arg1,"arg2",NULL)

I think I need to use the script rather than a program in this post.
Why i call it as a program is the DRDOS multitasking windos is
a tester OS for semiconductor. So, the vendor built their program
under the system.

I try to automate the user input for the program i called. the script i
try to call is spawnl(P_WAIT,"FETDIF11",NULL) it return the error
for me cause FETDIF11 is consider a script which only can run
through command prompt.
 

Re:system command for turbo c

daron wrote:
Quote
I try to use the spawn to call the script, but it also return the error for me.

I try to automate the user input for the program i called. the script i try to call is spawnl(P_WAIT,"FETDIF11",NULL) it return the error for me cause FETDIF11 is consider a script which only can run through command prompt.
Is your "FETDIF11" actually "FETDIF11.BAT" ?
I may be misremembering, but I seem to recall that DR had a program
called BATCH that executed scripts.
In any case, specifying the ".BAT" would be helpfull to the command
interpreter.
Use the method Ed just showed you, as to how to properly use the
COMSPEC
spawnl(P_WAIT, comspec, comspec, "/C", "FETDIF11.BAT", NULL);
Note also that you might need to specify the full path for FETDIF11.
 

Re:system command for turbo c

you are right, this work in drdos. Thanks
The script i called is a interactive script, it required the input from users. Is possible to trigger the interrupt to input the data to the script i called instead key in by user? any recommendations resources for this?
Regards
Daron
"Ed Mulroy" < XXXX@XXXXX.COM >wrote:
Quote
I do not think you are doing it correctly. Look at this example, given as a
screen capture. The paths are explicitly given in the commands is because I
have not set and configured as appropriate for TC 2.01. You should not need
to specify them.

If DRDOS works correctly for you then good. However, back when DOS had not
yet become obsolete, DRDOS always suffered from problems due to bugs which
were side effects induced by the various added "enhancements". If this does
not work on your machine then it is more likely to be a situation in which
DRDOS is not compatible with DOS even 'though it is said by the developers
to be compatible.

====================================
C:\Documents and Settings\Edward\My Documents\Lookat\q020
>ver

Microsoft Windows XP [Version 5.1.2600]

C:\Documents and Settings\Edward\My Documents\Lookat\q020
>type ques020.c
#include <stdio.h>
#include <stdlib.h>
#include <process.h>

int main()
{
char *comspec = getenv("COMSPEC");

printf("------------\n");
spawnl(
P_WAIT,
comspec,
comspec, /* argv[0] is the program name */
"/C", /* option telling command interpreter to not stay resident */
"dir c:\\tc\\*.*",
NULL
);
printf("------------\n");
return 0;
}


>C:\Documents and Settings\Edward\My Documents\Lookat\q020
>make
MAKE Version 5.2 Copyright (c) 1987, 2000 Borland
c:\tc\tcc -c -ms -Ic:\tc\include c:ques020.c
Turbo C Version 2.01 Copyright (c) 1987, 1988 Borland International
c:ques020.c:

Available memory 385342
c:\tc\tlink /x/c c:\tc\lib\c0s ques020,ques020,,c:\tc\lib\emu
c:\tc\lib\
cs
Turbo Link Version 2.0 Copyright (c) 1987, 1988 Borland International

C:\Documents and Settings\Edward\My Documents\Lookat\q020
>ques020
------------

Volume in drive C has no label
Volume Serial Number is FC8D-A209
Directory of C:\TC

. <DIR>06/07/05 11:54a
.. <DIR>06/07/05 11:54a
ACCOUNTS TXT 15941 02/18/05 5:33a
ACCTS C 2466 06/08/05 4:52p
ACCTS EXE 25492 06/08/05 5:08p
ACCTS H 427 06/08/05 4:43p
ACCTS MAK 192 06/08/05 5:05p
ACCTS OBJ 3132 06/08/05 5:08p
ACCTS2 C 764 06/08/05 4:52p
ACCTS2 OBJ 1489 06/08/05 5:08p
BGI <DIR>06/08/05 11:37a
CINSTXFR EXE 18060 05/11/89 2:01a
CPP EXE 59855 05/11/89 2:01a
EXAMPLES <DIR>06/08/05 11:38a
GREP COM 7029 05/11/89 2:01a
HELPME! DOC 17971 05/11/89 2:01a
INCLUDE <DIR>06/07/05 11:54a
LIB <DIR>06/07/05 11:54a
MAKE EXE 27174 05/11/89 2:01a
OBJXREF COM 30952 05/11/89 2:01a
README 20884 05/11/89 2:01a
README COM 4201 05/11/89 2:01a
REDIR01 TXT 109 06/08/05 5:06p
SHOWIT C 359 06/08/05 5:02p
SHOWIT EXE 8980 06/08/05 5:03p
SHOWIT OBJ 520 06/08/05 5:03p
TC EXE 290525 05/11/89 2:01a
TCC EXE 180385 05/11/89 2:01a
TCCONFIG EXE 15522 05/11/89 2:01a
TCCONFIG TC 1690 06/07/05 5:32p
TCHELP TCH 219688 05/11/89 2:01a
TCINST EXE 79824 05/11/89 2:01a
THELP COM 28246 06/07/05 11:54a
THELP DOC 12682 05/11/89 2:01a
TLIB EXE 30876 05/11/89 2:01a
TLINK EXE 21717 05/11/89 2:01a
TOUCH COM 3992 05/11/89 2:01a
TURBOC CFG 30 06/07/05 11:54a
UNPACK COM 14710 05/11/89 2:01a
39 file(s) 1145884 bytes
1023932928 bytes free
------------

C:\DOCUME~1\Edward\MYDOCU~1\Lookat\q020
>
====================================

 

Re:system command for turbo c

FETDIF11 is not a batch file, i called it as a script in here. same like dir command, I cannot find the file of FETDIF11 also.
Bob Gonder < XXXX@XXXXX.COM >wrote:
Quote
daron wrote:

>I try to use the spawn to call the script, but it also return the error for me.
>
>I try to automate the user input for the program i called. the script i try to call is spawnl(P_WAIT,"FETDIF11",NULL) it return the error for me cause FETDIF11 is consider a script which only can run through command prompt.

Is your "FETDIF11" actually "FETDIF11.BAT" ?

I may be misremembering, but I seem to recall that DR had a program
called BATCH that executed scripts.

In any case, specifying the ".BAT" would be helpfull to the command
interpreter.

Use the method Ed just showed you, as to how to properly use the
COMSPEC

spawnl(P_WAIT, comspec, comspec, "/C", "FETDIF11.BAT", NULL);

Note also that you might need to specify the full path for FETDIF11.


 

Re:system command for turbo c

Sorry, but it has been too long since I did that. I no longer remember the
details of how to stuff keystrokes into the keyboard buffer. Try looking in
the Snippets archive here:
snippets.snippets.org/index.php
. Ed
Quote
daron wrote in message
news:431828e5$ XXXX@XXXXX.COM ...

you are right, this work in drdos. Thanks

The script i called is a interactive script, it required the input
from users. Is possible to trigger the interrupt to input the
data to the script i called instead key in by user? any
recommendations resources for this?
 

Re:system command for turbo c

daron wrote:
Quote
The script i called is a interactive script, it required the input from users. Is possible to trigger the interrupt to input the data to the script i called instead key in by user?
How about redirection?
spawnl(P_WAIT, comspec, comspec, "/C", "FETDIF11", "<inputfile",
NULL);
 

Re:system command for turbo c

Thank for u guy help
I did find the solution to automate the process already.
spawnl(P_WAIT, comspec, comspec, "/C", "FETDIF11", "<","INPUT FILE",
NULL);
"<" is work for most dos to indirect the input by using a text file.
Regards
Daron