source code for system() routine 
Author Message
 source code for system() routine

Quote:

> Help!!!

> The compiler I'm using (CodeWarrior for Windows), doesn't include the system()
> routine in stdlib.h, well it's there, but it doesn't do anything!!!

> Can someone please supply me with the routine so that I can run programmes
> from within programmes, make calls to DOS etc., etc., etc.

> Thanks in advance

MS Windows, in its 16-bit-version, doesn't have a command processor
(which you can find out with a system(NULL) call), so there's no way to
implement system() on this system in a meaningful way.

Furthermore, you can't get the routine from somewhere and expect it to
work; it has to come with your compiler because system() is a part of
the standard library.

To start programs in MS windows, use the API function WinExec().



Thu, 24 Aug 2000 03:00:00 GMT  
 source code for system() routine



Quote:
>Help!!!

>The compiler I'm using (CodeWarrior for Windows), doesn't include the system()
>routine in stdlib.h, well it's there, but it doesn't do anything!!!

>Can someone please supply me with the routine so that I can run programmes
>from within programmes, make calls to DOS etc., etc., etc.

system() is the only method that C provides to run external commands. If that
doesn't work you'll have to look beyond the C language at platform-specific
extensions. Try asking in a Windows related newsgroup such as
comp.os.ms-windows.programmer.misc.

--
-----------------------------------------


-----------------------------------------



Fri, 25 Aug 2000 03:00:00 GMT  
 source code for system() routine



Quote:

>> Help!!!

>> The compiler I'm using (CodeWarrior for Windows), doesn't include the system()>> routine in stdlib.h, well it's there, but it doesn't do anything!!!

>> Can someone please supply me with the routine so that I can run programmes
>> from within programmes, make calls to DOS etc., etc., etc.

>> Thanks in advance

>MS Windows, in its 16-bit-version, doesn't have a command processor
>(which you can find out with a system(NULL) call), so there's no way to
>implement system() on this system in a meaningful way.

...

Quote:
>To start programs in MS windows, use the API function WinExec().

Wouldn't building system() as a veneer for WinExec() implement it in a
meaningful way on that platform?

--
-----------------------------------------


-----------------------------------------



Sat, 26 Aug 2000 03:00:00 GMT  
 source code for system() routine

Quote:




> >> Help!!!

> >> The compiler I'm using (CodeWarrior for Windows), doesn't include the system()>> routine in stdlib.h, well it's there, but it doesn't do anything!!!

> >> Can someone please supply me with the routine so that I can run programmes
> >> from within programmes, make calls to DOS etc., etc., etc.

> >> Thanks in advance

> >MS Windows, in its 16-bit-version, doesn't have a command processor
> >(which you can find out with a system(NULL) call), so there's no way to
> >implement system() on this system in a meaningful way.

> ...

> >To start programs in MS windows, use the API function WinExec().

> Wouldn't building system() as a veneer for WinExec() implement it in a
> meaningful way on that platform?

Hmhm... After looking it up, yes, with some brute force. There's still
the lack of a 'command processor' that would have to be 'executed'.
You'd have to define the 'WinExec()' code as a command processor; while
this would of course be possible, it is not what one might expect.
There's no return value from the executed command (in fact there's no
clean way to wait for the command to complete), there's not the least
bit of a shell; you only get your command started.

Admittedly the standard doesn't impose any such limitations on the
'command processor', but as Win16 is a freestanding implementation
anyway (with the 'WinMain()' instead of 'main()') why not drop
'system()' if it had to be such a {*filter*} implementation? It would surely
break applications that expect the command to complete before system()
returns.

I guess they don't have stdout and stdin for the same reason - it would
have to be a not-really-working stub, so they dropped it. In early
versions, there wasn't even malloc() or fopen() (use GlobalAlloc() or
some assembler instead).



Sat, 26 Aug 2000 03:00:00 GMT  
 source code for system() routine





|?
|> >MS Windows, in its 16-bit-version, doesn't have a command processor
|> >(which you can find out with a system(NULL) call), so there's no way to
|> >implement system() on this system in a meaningful way.
|>
|> >To start programs in MS windows, use the API function WinExec().
|>
|> Wouldn't building system() as a veneer for WinExec() implement it in a
|> meaningful way on that platform?

Unfortunately, that would give strictly-conforming C programs an
even greater chance of correctly translating and executing in the
Windows environment; this is clearly unacceptable.

Regards,

--
Chris Engebretson - Raytheon STX Corporation | Ph#: (605)594-6829
USGS EROS Data Center, Sioux Falls, SD 57198 | Fax: (605)594-6940

Opinions are not those of  Raytheon Systems Company  or the USGS.



Sat, 26 Aug 2000 03:00:00 GMT  
 source code for system() routine


Quote:




>>> Help!!!

>>> The compiler I'm using (CodeWarrior for Windows), doesn't include the system()>> routine in stdlib.h, well it's there, but it doesn't do anything!!!

>>> Can someone please supply me with the routine so that I can run programmes
>>> from within programmes, make calls to DOS etc., etc., etc.

>>> Thanks in advance

>>MS Windows, in its 16-bit-version, doesn't have a command processor
>>(which you can find out with a system(NULL) call), so there's no way to
>>implement system() on this system in a meaningful way.

>...

>>To start programs in MS windows, use the API function WinExec().

>Wouldn't building system() as a veneer for WinExec() implement it in a
>meaningful way on that platform?

Visual C++ does essentially that, except it uses CreateProcess()
instead of WinExec().  The code to do this is quite complicated.
--
Michael M Rubenstein


Sat, 26 Aug 2000 03:00:00 GMT  
 source code for system() routine

Quote:




> > > Help!!!

> > > The compiler I'm using (CodeWarrior for Windows), doesn't include the
> system()
> > > routine in stdlib.h, well it's there, but it doesn't do anything!!!

> > > Can someone please supply me with the routine so that I can run programmes
> > > from within programmes, make calls to DOS etc., etc., etc.

> > > Thanks in advance

> > MS Windows, in its 16-bit-version, doesn't have a command processor
> > (which you can find out with a system(NULL) call), so there's no way to
> > implement system() on this system in a meaningful way.

> > Furthermore, you can't get the routine from somewhere and expect it to
> > work; it has to come with your compiler because system() is a part of
> > the standard library.

> > To start programs in MS windows, use the API function WinExec().

> All this discussion is great, but how could I do the equivalant of the DOS
> command 'type readme.txt | more' from within my programme?

You *cannot* in conforming C in 16-bit-windows; the best you can do is:

- find the command processor, which should be given in the environment
variable 'COMSPEC', with getenv(). Will normally be 'command.com'

- invoke that with the desired command like
        WinExec("your_comspec_here /c your_command_here", SW_SHOWNORMAL)
  The "/c" is a bold guess; if you don't have 'command.com' as a command
processor, this might be wrong.

- before that, provide a sensible PIF-file for the command processor

- be carefull not to launch windows-programs this way, because
command.com can't start windows-programs. Don't ask me how to
distinguish windows-programs from DOS-programs given the name of the
executable.

See how ugly it is, and why they don't try to make system() work?

Have fun,
        Bernd



Mon, 28 Aug 2000 03:00:00 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. Source code for sorting routines

2. Source code for sprintf and sscanf routines??

3. C library routines source code

4. Looking for math routines source code

5. Mouse routine source code for games

6. Help needed for source code of library routines

7. how to convert source code pascal to source code c

8. ANNOUNCEMENT: Visual C++, iTcl source code system

9. Alternative source code control system wanted

10. Java source code to CSharp source code converter

11. mp3 source code ? - Source.zip (1/1)

12. mp3 source code ? - Source.zip (0/1)

 

 
Powered by phpBB® Forum Software