DOS, create pipe for stdin/stdout of command.com(or 4dos.com) in C or Batch?How does the command.com shell work with MS-DOS?VT52 emulation for MS-DOS?Does ancient UNIX create a new shell process for each terminal?Which tools were used to create the C language?What are these tiny TSRs doing?An old DOS application that allowed to create cards, posters, invitations, etcHow do I create a boot menu to select between Windows and DOS?How do I compile C code with the IRIX X Window System?Gotek drives for MS-DOS (plus few more constraints)Alternatives for TurboVision on DOS

The use of multiple foreign keys on same column in SQL Server

How can I hide my bitcoin transactions to protect anonymity from others?

Is it legal for company to use my work email to pretend I still work there?

Email Account under attack (really) - anything I can do?

TGV timetables / schedules?

Do Phineas and Ferb ever actually get busted in real time?

Pronouncing Dictionary.com's W.O.D "vade mecum" in English

How to report a triplet of septets in NMR tabulation?

If two metric spaces are topologically equivalent (homeomorphic) imply that they are complete?

Why is an old chain unsafe?

Animated Series: Alien black spider robot crashes on Earth

A Journey Through Space and Time

How long does it take to type this?

Motorized valve interfering with button?

DOS, create pipe for stdin/stdout of command.com(or 4dos.com) in C or Batch?

Japan - Plan around max visa duration

A function which translates a sentence to title-case

How old can references or sources in a thesis be?

What defenses are there against being summoned by the Gate spell?

Why has Russell's definition of numbers using equivalence classes been finally abandonned? ( If it has actually been abandonned).

Mathematical cryptic clues

XeLaTeX and pdfLaTeX ignore hyphenation

Relation between Frobenius, spectral norm and sum of maxima

Can I interfere when another PC is about to be attacked?



DOS, create pipe for stdin/stdout of command.com(or 4dos.com) in C or Batch?


How does the command.com shell work with MS-DOS?VT52 emulation for MS-DOS?Does ancient UNIX create a new shell process for each terminal?Which tools were used to create the C language?What are these tiny TSRs doing?An old DOS application that allowed to create cards, posters, invitations, etcHow do I create a boot menu to select between Windows and DOS?How do I compile C code with the IRIX X Window System?Gotek drives for MS-DOS (plus few more constraints)Alternatives for TurboVision on DOS













3















I'm working on a retro project and was trying to create a pipe of stdin/out/err in DOS, but I can't find any functions to to this?



For instance the pipe() command from unistd.h isn't present in BorlandC, which I'm using.



Can anyone tell me how to to this? Preferably in C or Batch.



Also, how to pipe stdin/out from the current shell (command.com or 4dos.com) in order to "Skin" the console?










share|improve this question









New contributor




Dacobi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Are you aware of the Cygwin project ( cygwin.com ) ? It provides Windows the infrastructure compile and run many GNU programs. Included is a terminal program which has many POSIX features. See also: stackoverflow.com/questions/12468913

    – RichF
    5 hours ago











  • I know you are working on a retro project, but if working on a modern Windows system there is powershell.exe. I believe it is fully POSIX compatible and comes with the OS. It is obviously not a retro tool, though.

    – RichF
    4 hours ago












  • One way to circumvent this, for the skinning part at least, may be the use of a device driver.

    – Raffzahn
    3 hours ago















3















I'm working on a retro project and was trying to create a pipe of stdin/out/err in DOS, but I can't find any functions to to this?



For instance the pipe() command from unistd.h isn't present in BorlandC, which I'm using.



Can anyone tell me how to to this? Preferably in C or Batch.



Also, how to pipe stdin/out from the current shell (command.com or 4dos.com) in order to "Skin" the console?










share|improve this question









New contributor




Dacobi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Are you aware of the Cygwin project ( cygwin.com ) ? It provides Windows the infrastructure compile and run many GNU programs. Included is a terminal program which has many POSIX features. See also: stackoverflow.com/questions/12468913

    – RichF
    5 hours ago











  • I know you are working on a retro project, but if working on a modern Windows system there is powershell.exe. I believe it is fully POSIX compatible and comes with the OS. It is obviously not a retro tool, though.

    – RichF
    4 hours ago












  • One way to circumvent this, for the skinning part at least, may be the use of a device driver.

    – Raffzahn
    3 hours ago













3












3








3








I'm working on a retro project and was trying to create a pipe of stdin/out/err in DOS, but I can't find any functions to to this?



For instance the pipe() command from unistd.h isn't present in BorlandC, which I'm using.



Can anyone tell me how to to this? Preferably in C or Batch.



Also, how to pipe stdin/out from the current shell (command.com or 4dos.com) in order to "Skin" the console?










share|improve this question









New contributor




Dacobi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I'm working on a retro project and was trying to create a pipe of stdin/out/err in DOS, but I can't find any functions to to this?



For instance the pipe() command from unistd.h isn't present in BorlandC, which I'm using.



Can anyone tell me how to to this? Preferably in C or Batch.



Also, how to pipe stdin/out from the current shell (command.com or 4dos.com) in order to "Skin" the console?







ms-dos c shell






share|improve this question









New contributor




Dacobi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Dacobi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 8 hours ago







Dacobi













New contributor




Dacobi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 9 hours ago









DacobiDacobi

254




254




New contributor




Dacobi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Dacobi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Dacobi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • Are you aware of the Cygwin project ( cygwin.com ) ? It provides Windows the infrastructure compile and run many GNU programs. Included is a terminal program which has many POSIX features. See also: stackoverflow.com/questions/12468913

    – RichF
    5 hours ago











  • I know you are working on a retro project, but if working on a modern Windows system there is powershell.exe. I believe it is fully POSIX compatible and comes with the OS. It is obviously not a retro tool, though.

    – RichF
    4 hours ago












  • One way to circumvent this, for the skinning part at least, may be the use of a device driver.

    – Raffzahn
    3 hours ago

















  • Are you aware of the Cygwin project ( cygwin.com ) ? It provides Windows the infrastructure compile and run many GNU programs. Included is a terminal program which has many POSIX features. See also: stackoverflow.com/questions/12468913

    – RichF
    5 hours ago











  • I know you are working on a retro project, but if working on a modern Windows system there is powershell.exe. I believe it is fully POSIX compatible and comes with the OS. It is obviously not a retro tool, though.

    – RichF
    4 hours ago












  • One way to circumvent this, for the skinning part at least, may be the use of a device driver.

    – Raffzahn
    3 hours ago
















Are you aware of the Cygwin project ( cygwin.com ) ? It provides Windows the infrastructure compile and run many GNU programs. Included is a terminal program which has many POSIX features. See also: stackoverflow.com/questions/12468913

– RichF
5 hours ago





Are you aware of the Cygwin project ( cygwin.com ) ? It provides Windows the infrastructure compile and run many GNU programs. Included is a terminal program which has many POSIX features. See also: stackoverflow.com/questions/12468913

– RichF
5 hours ago













I know you are working on a retro project, but if working on a modern Windows system there is powershell.exe. I believe it is fully POSIX compatible and comes with the OS. It is obviously not a retro tool, though.

– RichF
4 hours ago






I know you are working on a retro project, but if working on a modern Windows system there is powershell.exe. I believe it is fully POSIX compatible and comes with the OS. It is obviously not a retro tool, though.

– RichF
4 hours ago














One way to circumvent this, for the skinning part at least, may be the use of a device driver.

– Raffzahn
3 hours ago





One way to circumvent this, for the skinning part at least, may be the use of a device driver.

– Raffzahn
3 hours ago










2 Answers
2






active

oldest

votes


















8














MS-DOS doesn't support pipes like Unix does - It does support input and output redirection through its command line processor COMMAND.COM, but that's a different thing.



If you're fine with pure I/O redirection, you should be able to do that using the system() function in C, by providing a command line that has the output redirection (<, >, |) included. Opposed to Unix, you will, however, not be able to have the "piped together" commands run in parallel, but rather only sequentially (which isn't quite what you need to scrape the console of an interactive program) - MS-DOS is not a multitasking system.






share|improve this answer

























  • Ok. The reason I asked was that I just had a long conversation with a guy on another forum, who said that people used to make CLI overlays to command.com, etc back in the day. But this doesn't seem possible with what you just said.

    – Dacobi
    8 hours ago






  • 3





    Well, you can, with using pure I/O redirection and quite a bit of ado (and people really did that): COMMAND.COM is just (nearly) a program like everything else in MS-DOS. If you do a system ("COMMAND.COM DIR>C:TMPDIR.TXT") and later parse dir.txt, you might be able to achieve what you are looking for. But you obviously need to implement any command you want to support by a separate system call. And that obviously won't work well with interactive commands.

    – tofro
    7 hours ago












  • @Dacobi Since programms can have child programs, these can act as new shell (CLI) for the user and thus replacing Command.com for most parts (or even be started instead) - still, they can't change the nature of the OS. So what's possible or not will be different from what you'd know from a Unix-alike system. Starting with the problem that DOS programs often not write their output STDOUT, but use means of BIOS or direct screen manipulation.

    – Raffzahn
    4 hours ago


















4














It seams as if you imply that DOS is kind of an unixoide OS, which it isn't. While Microsoft's goal with MS-DOS 2.0 was to move it toward Unix like operations, for compatibility with Xenix, it never went all the way. Not in internal workings nor API or shell. MS-DOS is a single user, single Process OS - with a few 'handmade' exceptions like TSR.




For instance the pipe() command from unistd.h isn't present in BorlandC, which I'm using.




UNISTD is a POSIX definition. DOS isn't a POSIX system. POSIX definitions where made years after DOS got unix alike features.



DOS implements STDIN/OUT/ERR. They are made as simple file handles (0,1,2) to be read from/writen to and inherited from the parent program.




Can anyone tell me how to to this? Preferably in C or Batch.




Just use redirection one the command line in the usual way via </|/>




Also, how to pipe stdin/out from the current shell (command.com or 4dos.com) in order to "Skin" the console?




You might get a hard time, as DOS can only run a single single program at a time. Without two concurent processes it's just not possible to transfer data between tehm.



Workings of Rediection in DOS



When pipeing (redirection to a program) is used, all output of the first program to STDOUT gets writen into a temporary file until the program terminates. Then the next program gets started (after the first is unloaded) and the file written is assigned to STDIN (and deleted when this program terminates).



It is of course is different when devices are used. Here access is immediate and concurent.



So unless you spread your programs across mutiple DOS machines, you can't come close to unix behaviour (*1).





I'm working on a retro project and was trying to create a pipe of stdin/out/err in DOS, but I can't find any functions to to this?




See, that's the true lesson of retrocomputing: these old machines and OSes were not the same as today, just in small, slow and with blocky graphics, they where different. And not just between today and back then, but as well between different manufactures and even machines. Backporting ideas isn't about finding the same function, but to work from a complete different angle.



Discovering unknown space with different laws of physic :))




Now, having said all of this and taking the assumption of adding bells and whistles to STDOUT), a clean way to do this would be writing a character driver and assign them as STDIN/OUT when starting command.com. If the driver is (for example) named skinner.dev and the resulting device would be SKINNER, then config.sys needs to contain these lines (2):



DEVICE=C:DRIVERSKINNER.DEV
SHELL=C:COMMAND.COM SKINNER


And from there on, all output to STDOUT is delivered thru your driver - unless redirected that is. Now you may add any kind of framing skins or whatsoever. Keep in mind that the Application might not be aware of and for example still assume a 24x80 screen, even if you took some characters off for a beautiful frame. Similar any output bypassing STDOUT, like when using BIOS calls or direkt screen manipulation, may show up at the wrong place (*3). Last but not least, every program opening CON on its own will as well bypass your driver.



A few points to think about may be:



  • Don't forget to make the driver as well handling read requests, as Command.Com requires both ways to go thru the same device.


  • You may as well try to replace the build-in CON driver(*4), this means setting the CON bit in the device attributes word as well as replacing/capturing INT 29h, as DOS does handle CON a bit different. (*5)


  • Adding I/O-Control support would support a clean interface to set the workings during runtime (changing colours or whatsoever it does) with a configuration command supplied by you.


  • Do your users a favour and use Assembly - at least for the driver.


Device drivers can be a lot of fun and are usually way less complicated to write then people tend to assume.



Caveat: Some mechanics only work with DOS 3.1 and higher even thoug already defined before. This goes especially for monitoring open/close calls.




*1 - And even then you may need some file server allowing read while write and plunge in a zillion FLUSH calls to make each output seen.



*2 - For test purpose it may be more appropriate to only load the driver and use redirected STDIN/OUT only via a sub-shell.



*3 - Some of this may be captured by the driver due manipulation of BIOS data and alike - but that will as well lead to a slow creep into machine and OS dependence while at the same time bloating code ever more.



*4 - This would remove some of the possible ways to screw up things for child processes in complex scenarios involving sub-shells as well as redirections with the explicit use of CON. On the down side, you'd have to rewrite all of it's functionality - hopefully compatible with ANSI.SYS which already is one.



*5 - Which BTW would be the better way (when going this route) - get the source for some ANSI.SYS compatible driver like NANSI.SYS and tweek it to support your additional functionality - more work than writing your own, but for sure a great drop in by naming it ANSI.SYS and copying it onto any machine available - not other change needed.






share|improve this answer

























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "648"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    noCode: true, onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );






    Dacobi is a new contributor. Be nice, and check out our Code of Conduct.









    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fretrocomputing.stackexchange.com%2fquestions%2f9609%2fdos-create-pipe-for-stdin-stdout-of-command-comor-4dos-com-in-c-or-batch%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    8














    MS-DOS doesn't support pipes like Unix does - It does support input and output redirection through its command line processor COMMAND.COM, but that's a different thing.



    If you're fine with pure I/O redirection, you should be able to do that using the system() function in C, by providing a command line that has the output redirection (<, >, |) included. Opposed to Unix, you will, however, not be able to have the "piped together" commands run in parallel, but rather only sequentially (which isn't quite what you need to scrape the console of an interactive program) - MS-DOS is not a multitasking system.






    share|improve this answer

























    • Ok. The reason I asked was that I just had a long conversation with a guy on another forum, who said that people used to make CLI overlays to command.com, etc back in the day. But this doesn't seem possible with what you just said.

      – Dacobi
      8 hours ago






    • 3





      Well, you can, with using pure I/O redirection and quite a bit of ado (and people really did that): COMMAND.COM is just (nearly) a program like everything else in MS-DOS. If you do a system ("COMMAND.COM DIR>C:TMPDIR.TXT") and later parse dir.txt, you might be able to achieve what you are looking for. But you obviously need to implement any command you want to support by a separate system call. And that obviously won't work well with interactive commands.

      – tofro
      7 hours ago












    • @Dacobi Since programms can have child programs, these can act as new shell (CLI) for the user and thus replacing Command.com for most parts (or even be started instead) - still, they can't change the nature of the OS. So what's possible or not will be different from what you'd know from a Unix-alike system. Starting with the problem that DOS programs often not write their output STDOUT, but use means of BIOS or direct screen manipulation.

      – Raffzahn
      4 hours ago















    8














    MS-DOS doesn't support pipes like Unix does - It does support input and output redirection through its command line processor COMMAND.COM, but that's a different thing.



    If you're fine with pure I/O redirection, you should be able to do that using the system() function in C, by providing a command line that has the output redirection (<, >, |) included. Opposed to Unix, you will, however, not be able to have the "piped together" commands run in parallel, but rather only sequentially (which isn't quite what you need to scrape the console of an interactive program) - MS-DOS is not a multitasking system.






    share|improve this answer

























    • Ok. The reason I asked was that I just had a long conversation with a guy on another forum, who said that people used to make CLI overlays to command.com, etc back in the day. But this doesn't seem possible with what you just said.

      – Dacobi
      8 hours ago






    • 3





      Well, you can, with using pure I/O redirection and quite a bit of ado (and people really did that): COMMAND.COM is just (nearly) a program like everything else in MS-DOS. If you do a system ("COMMAND.COM DIR>C:TMPDIR.TXT") and later parse dir.txt, you might be able to achieve what you are looking for. But you obviously need to implement any command you want to support by a separate system call. And that obviously won't work well with interactive commands.

      – tofro
      7 hours ago












    • @Dacobi Since programms can have child programs, these can act as new shell (CLI) for the user and thus replacing Command.com for most parts (or even be started instead) - still, they can't change the nature of the OS. So what's possible or not will be different from what you'd know from a Unix-alike system. Starting with the problem that DOS programs often not write their output STDOUT, but use means of BIOS or direct screen manipulation.

      – Raffzahn
      4 hours ago













    8












    8








    8







    MS-DOS doesn't support pipes like Unix does - It does support input and output redirection through its command line processor COMMAND.COM, but that's a different thing.



    If you're fine with pure I/O redirection, you should be able to do that using the system() function in C, by providing a command line that has the output redirection (<, >, |) included. Opposed to Unix, you will, however, not be able to have the "piped together" commands run in parallel, but rather only sequentially (which isn't quite what you need to scrape the console of an interactive program) - MS-DOS is not a multitasking system.






    share|improve this answer















    MS-DOS doesn't support pipes like Unix does - It does support input and output redirection through its command line processor COMMAND.COM, but that's a different thing.



    If you're fine with pure I/O redirection, you should be able to do that using the system() function in C, by providing a command line that has the output redirection (<, >, |) included. Opposed to Unix, you will, however, not be able to have the "piped together" commands run in parallel, but rather only sequentially (which isn't quite what you need to scrape the console of an interactive program) - MS-DOS is not a multitasking system.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited 7 hours ago

























    answered 8 hours ago









    tofrotofro

    16.4k33392




    16.4k33392












    • Ok. The reason I asked was that I just had a long conversation with a guy on another forum, who said that people used to make CLI overlays to command.com, etc back in the day. But this doesn't seem possible with what you just said.

      – Dacobi
      8 hours ago






    • 3





      Well, you can, with using pure I/O redirection and quite a bit of ado (and people really did that): COMMAND.COM is just (nearly) a program like everything else in MS-DOS. If you do a system ("COMMAND.COM DIR>C:TMPDIR.TXT") and later parse dir.txt, you might be able to achieve what you are looking for. But you obviously need to implement any command you want to support by a separate system call. And that obviously won't work well with interactive commands.

      – tofro
      7 hours ago












    • @Dacobi Since programms can have child programs, these can act as new shell (CLI) for the user and thus replacing Command.com for most parts (or even be started instead) - still, they can't change the nature of the OS. So what's possible or not will be different from what you'd know from a Unix-alike system. Starting with the problem that DOS programs often not write their output STDOUT, but use means of BIOS or direct screen manipulation.

      – Raffzahn
      4 hours ago

















    • Ok. The reason I asked was that I just had a long conversation with a guy on another forum, who said that people used to make CLI overlays to command.com, etc back in the day. But this doesn't seem possible with what you just said.

      – Dacobi
      8 hours ago






    • 3





      Well, you can, with using pure I/O redirection and quite a bit of ado (and people really did that): COMMAND.COM is just (nearly) a program like everything else in MS-DOS. If you do a system ("COMMAND.COM DIR>C:TMPDIR.TXT") and later parse dir.txt, you might be able to achieve what you are looking for. But you obviously need to implement any command you want to support by a separate system call. And that obviously won't work well with interactive commands.

      – tofro
      7 hours ago












    • @Dacobi Since programms can have child programs, these can act as new shell (CLI) for the user and thus replacing Command.com for most parts (or even be started instead) - still, they can't change the nature of the OS. So what's possible or not will be different from what you'd know from a Unix-alike system. Starting with the problem that DOS programs often not write their output STDOUT, but use means of BIOS or direct screen manipulation.

      – Raffzahn
      4 hours ago
















    Ok. The reason I asked was that I just had a long conversation with a guy on another forum, who said that people used to make CLI overlays to command.com, etc back in the day. But this doesn't seem possible with what you just said.

    – Dacobi
    8 hours ago





    Ok. The reason I asked was that I just had a long conversation with a guy on another forum, who said that people used to make CLI overlays to command.com, etc back in the day. But this doesn't seem possible with what you just said.

    – Dacobi
    8 hours ago




    3




    3





    Well, you can, with using pure I/O redirection and quite a bit of ado (and people really did that): COMMAND.COM is just (nearly) a program like everything else in MS-DOS. If you do a system ("COMMAND.COM DIR>C:TMPDIR.TXT") and later parse dir.txt, you might be able to achieve what you are looking for. But you obviously need to implement any command you want to support by a separate system call. And that obviously won't work well with interactive commands.

    – tofro
    7 hours ago






    Well, you can, with using pure I/O redirection and quite a bit of ado (and people really did that): COMMAND.COM is just (nearly) a program like everything else in MS-DOS. If you do a system ("COMMAND.COM DIR>C:TMPDIR.TXT") and later parse dir.txt, you might be able to achieve what you are looking for. But you obviously need to implement any command you want to support by a separate system call. And that obviously won't work well with interactive commands.

    – tofro
    7 hours ago














    @Dacobi Since programms can have child programs, these can act as new shell (CLI) for the user and thus replacing Command.com for most parts (or even be started instead) - still, they can't change the nature of the OS. So what's possible or not will be different from what you'd know from a Unix-alike system. Starting with the problem that DOS programs often not write their output STDOUT, but use means of BIOS or direct screen manipulation.

    – Raffzahn
    4 hours ago





    @Dacobi Since programms can have child programs, these can act as new shell (CLI) for the user and thus replacing Command.com for most parts (or even be started instead) - still, they can't change the nature of the OS. So what's possible or not will be different from what you'd know from a Unix-alike system. Starting with the problem that DOS programs often not write their output STDOUT, but use means of BIOS or direct screen manipulation.

    – Raffzahn
    4 hours ago











    4














    It seams as if you imply that DOS is kind of an unixoide OS, which it isn't. While Microsoft's goal with MS-DOS 2.0 was to move it toward Unix like operations, for compatibility with Xenix, it never went all the way. Not in internal workings nor API or shell. MS-DOS is a single user, single Process OS - with a few 'handmade' exceptions like TSR.




    For instance the pipe() command from unistd.h isn't present in BorlandC, which I'm using.




    UNISTD is a POSIX definition. DOS isn't a POSIX system. POSIX definitions where made years after DOS got unix alike features.



    DOS implements STDIN/OUT/ERR. They are made as simple file handles (0,1,2) to be read from/writen to and inherited from the parent program.




    Can anyone tell me how to to this? Preferably in C or Batch.




    Just use redirection one the command line in the usual way via </|/>




    Also, how to pipe stdin/out from the current shell (command.com or 4dos.com) in order to "Skin" the console?




    You might get a hard time, as DOS can only run a single single program at a time. Without two concurent processes it's just not possible to transfer data between tehm.



    Workings of Rediection in DOS



    When pipeing (redirection to a program) is used, all output of the first program to STDOUT gets writen into a temporary file until the program terminates. Then the next program gets started (after the first is unloaded) and the file written is assigned to STDIN (and deleted when this program terminates).



    It is of course is different when devices are used. Here access is immediate and concurent.



    So unless you spread your programs across mutiple DOS machines, you can't come close to unix behaviour (*1).





    I'm working on a retro project and was trying to create a pipe of stdin/out/err in DOS, but I can't find any functions to to this?




    See, that's the true lesson of retrocomputing: these old machines and OSes were not the same as today, just in small, slow and with blocky graphics, they where different. And not just between today and back then, but as well between different manufactures and even machines. Backporting ideas isn't about finding the same function, but to work from a complete different angle.



    Discovering unknown space with different laws of physic :))




    Now, having said all of this and taking the assumption of adding bells and whistles to STDOUT), a clean way to do this would be writing a character driver and assign them as STDIN/OUT when starting command.com. If the driver is (for example) named skinner.dev and the resulting device would be SKINNER, then config.sys needs to contain these lines (2):



    DEVICE=C:DRIVERSKINNER.DEV
    SHELL=C:COMMAND.COM SKINNER


    And from there on, all output to STDOUT is delivered thru your driver - unless redirected that is. Now you may add any kind of framing skins or whatsoever. Keep in mind that the Application might not be aware of and for example still assume a 24x80 screen, even if you took some characters off for a beautiful frame. Similar any output bypassing STDOUT, like when using BIOS calls or direkt screen manipulation, may show up at the wrong place (*3). Last but not least, every program opening CON on its own will as well bypass your driver.



    A few points to think about may be:



    • Don't forget to make the driver as well handling read requests, as Command.Com requires both ways to go thru the same device.


    • You may as well try to replace the build-in CON driver(*4), this means setting the CON bit in the device attributes word as well as replacing/capturing INT 29h, as DOS does handle CON a bit different. (*5)


    • Adding I/O-Control support would support a clean interface to set the workings during runtime (changing colours or whatsoever it does) with a configuration command supplied by you.


    • Do your users a favour and use Assembly - at least for the driver.


    Device drivers can be a lot of fun and are usually way less complicated to write then people tend to assume.



    Caveat: Some mechanics only work with DOS 3.1 and higher even thoug already defined before. This goes especially for monitoring open/close calls.




    *1 - And even then you may need some file server allowing read while write and plunge in a zillion FLUSH calls to make each output seen.



    *2 - For test purpose it may be more appropriate to only load the driver and use redirected STDIN/OUT only via a sub-shell.



    *3 - Some of this may be captured by the driver due manipulation of BIOS data and alike - but that will as well lead to a slow creep into machine and OS dependence while at the same time bloating code ever more.



    *4 - This would remove some of the possible ways to screw up things for child processes in complex scenarios involving sub-shells as well as redirections with the explicit use of CON. On the down side, you'd have to rewrite all of it's functionality - hopefully compatible with ANSI.SYS which already is one.



    *5 - Which BTW would be the better way (when going this route) - get the source for some ANSI.SYS compatible driver like NANSI.SYS and tweek it to support your additional functionality - more work than writing your own, but for sure a great drop in by naming it ANSI.SYS and copying it onto any machine available - not other change needed.






    share|improve this answer





























      4














      It seams as if you imply that DOS is kind of an unixoide OS, which it isn't. While Microsoft's goal with MS-DOS 2.0 was to move it toward Unix like operations, for compatibility with Xenix, it never went all the way. Not in internal workings nor API or shell. MS-DOS is a single user, single Process OS - with a few 'handmade' exceptions like TSR.




      For instance the pipe() command from unistd.h isn't present in BorlandC, which I'm using.




      UNISTD is a POSIX definition. DOS isn't a POSIX system. POSIX definitions where made years after DOS got unix alike features.



      DOS implements STDIN/OUT/ERR. They are made as simple file handles (0,1,2) to be read from/writen to and inherited from the parent program.




      Can anyone tell me how to to this? Preferably in C or Batch.




      Just use redirection one the command line in the usual way via </|/>




      Also, how to pipe stdin/out from the current shell (command.com or 4dos.com) in order to "Skin" the console?




      You might get a hard time, as DOS can only run a single single program at a time. Without two concurent processes it's just not possible to transfer data between tehm.



      Workings of Rediection in DOS



      When pipeing (redirection to a program) is used, all output of the first program to STDOUT gets writen into a temporary file until the program terminates. Then the next program gets started (after the first is unloaded) and the file written is assigned to STDIN (and deleted when this program terminates).



      It is of course is different when devices are used. Here access is immediate and concurent.



      So unless you spread your programs across mutiple DOS machines, you can't come close to unix behaviour (*1).





      I'm working on a retro project and was trying to create a pipe of stdin/out/err in DOS, but I can't find any functions to to this?




      See, that's the true lesson of retrocomputing: these old machines and OSes were not the same as today, just in small, slow and with blocky graphics, they where different. And not just between today and back then, but as well between different manufactures and even machines. Backporting ideas isn't about finding the same function, but to work from a complete different angle.



      Discovering unknown space with different laws of physic :))




      Now, having said all of this and taking the assumption of adding bells and whistles to STDOUT), a clean way to do this would be writing a character driver and assign them as STDIN/OUT when starting command.com. If the driver is (for example) named skinner.dev and the resulting device would be SKINNER, then config.sys needs to contain these lines (2):



      DEVICE=C:DRIVERSKINNER.DEV
      SHELL=C:COMMAND.COM SKINNER


      And from there on, all output to STDOUT is delivered thru your driver - unless redirected that is. Now you may add any kind of framing skins or whatsoever. Keep in mind that the Application might not be aware of and for example still assume a 24x80 screen, even if you took some characters off for a beautiful frame. Similar any output bypassing STDOUT, like when using BIOS calls or direkt screen manipulation, may show up at the wrong place (*3). Last but not least, every program opening CON on its own will as well bypass your driver.



      A few points to think about may be:



      • Don't forget to make the driver as well handling read requests, as Command.Com requires both ways to go thru the same device.


      • You may as well try to replace the build-in CON driver(*4), this means setting the CON bit in the device attributes word as well as replacing/capturing INT 29h, as DOS does handle CON a bit different. (*5)


      • Adding I/O-Control support would support a clean interface to set the workings during runtime (changing colours or whatsoever it does) with a configuration command supplied by you.


      • Do your users a favour and use Assembly - at least for the driver.


      Device drivers can be a lot of fun and are usually way less complicated to write then people tend to assume.



      Caveat: Some mechanics only work with DOS 3.1 and higher even thoug already defined before. This goes especially for monitoring open/close calls.




      *1 - And even then you may need some file server allowing read while write and plunge in a zillion FLUSH calls to make each output seen.



      *2 - For test purpose it may be more appropriate to only load the driver and use redirected STDIN/OUT only via a sub-shell.



      *3 - Some of this may be captured by the driver due manipulation of BIOS data and alike - but that will as well lead to a slow creep into machine and OS dependence while at the same time bloating code ever more.



      *4 - This would remove some of the possible ways to screw up things for child processes in complex scenarios involving sub-shells as well as redirections with the explicit use of CON. On the down side, you'd have to rewrite all of it's functionality - hopefully compatible with ANSI.SYS which already is one.



      *5 - Which BTW would be the better way (when going this route) - get the source for some ANSI.SYS compatible driver like NANSI.SYS and tweek it to support your additional functionality - more work than writing your own, but for sure a great drop in by naming it ANSI.SYS and copying it onto any machine available - not other change needed.






      share|improve this answer



























        4












        4








        4







        It seams as if you imply that DOS is kind of an unixoide OS, which it isn't. While Microsoft's goal with MS-DOS 2.0 was to move it toward Unix like operations, for compatibility with Xenix, it never went all the way. Not in internal workings nor API or shell. MS-DOS is a single user, single Process OS - with a few 'handmade' exceptions like TSR.




        For instance the pipe() command from unistd.h isn't present in BorlandC, which I'm using.




        UNISTD is a POSIX definition. DOS isn't a POSIX system. POSIX definitions where made years after DOS got unix alike features.



        DOS implements STDIN/OUT/ERR. They are made as simple file handles (0,1,2) to be read from/writen to and inherited from the parent program.




        Can anyone tell me how to to this? Preferably in C or Batch.




        Just use redirection one the command line in the usual way via </|/>




        Also, how to pipe stdin/out from the current shell (command.com or 4dos.com) in order to "Skin" the console?




        You might get a hard time, as DOS can only run a single single program at a time. Without two concurent processes it's just not possible to transfer data between tehm.



        Workings of Rediection in DOS



        When pipeing (redirection to a program) is used, all output of the first program to STDOUT gets writen into a temporary file until the program terminates. Then the next program gets started (after the first is unloaded) and the file written is assigned to STDIN (and deleted when this program terminates).



        It is of course is different when devices are used. Here access is immediate and concurent.



        So unless you spread your programs across mutiple DOS machines, you can't come close to unix behaviour (*1).





        I'm working on a retro project and was trying to create a pipe of stdin/out/err in DOS, but I can't find any functions to to this?




        See, that's the true lesson of retrocomputing: these old machines and OSes were not the same as today, just in small, slow and with blocky graphics, they where different. And not just between today and back then, but as well between different manufactures and even machines. Backporting ideas isn't about finding the same function, but to work from a complete different angle.



        Discovering unknown space with different laws of physic :))




        Now, having said all of this and taking the assumption of adding bells and whistles to STDOUT), a clean way to do this would be writing a character driver and assign them as STDIN/OUT when starting command.com. If the driver is (for example) named skinner.dev and the resulting device would be SKINNER, then config.sys needs to contain these lines (2):



        DEVICE=C:DRIVERSKINNER.DEV
        SHELL=C:COMMAND.COM SKINNER


        And from there on, all output to STDOUT is delivered thru your driver - unless redirected that is. Now you may add any kind of framing skins or whatsoever. Keep in mind that the Application might not be aware of and for example still assume a 24x80 screen, even if you took some characters off for a beautiful frame. Similar any output bypassing STDOUT, like when using BIOS calls or direkt screen manipulation, may show up at the wrong place (*3). Last but not least, every program opening CON on its own will as well bypass your driver.



        A few points to think about may be:



        • Don't forget to make the driver as well handling read requests, as Command.Com requires both ways to go thru the same device.


        • You may as well try to replace the build-in CON driver(*4), this means setting the CON bit in the device attributes word as well as replacing/capturing INT 29h, as DOS does handle CON a bit different. (*5)


        • Adding I/O-Control support would support a clean interface to set the workings during runtime (changing colours or whatsoever it does) with a configuration command supplied by you.


        • Do your users a favour and use Assembly - at least for the driver.


        Device drivers can be a lot of fun and are usually way less complicated to write then people tend to assume.



        Caveat: Some mechanics only work with DOS 3.1 and higher even thoug already defined before. This goes especially for monitoring open/close calls.




        *1 - And even then you may need some file server allowing read while write and plunge in a zillion FLUSH calls to make each output seen.



        *2 - For test purpose it may be more appropriate to only load the driver and use redirected STDIN/OUT only via a sub-shell.



        *3 - Some of this may be captured by the driver due manipulation of BIOS data and alike - but that will as well lead to a slow creep into machine and OS dependence while at the same time bloating code ever more.



        *4 - This would remove some of the possible ways to screw up things for child processes in complex scenarios involving sub-shells as well as redirections with the explicit use of CON. On the down side, you'd have to rewrite all of it's functionality - hopefully compatible with ANSI.SYS which already is one.



        *5 - Which BTW would be the better way (when going this route) - get the source for some ANSI.SYS compatible driver like NANSI.SYS and tweek it to support your additional functionality - more work than writing your own, but for sure a great drop in by naming it ANSI.SYS and copying it onto any machine available - not other change needed.






        share|improve this answer















        It seams as if you imply that DOS is kind of an unixoide OS, which it isn't. While Microsoft's goal with MS-DOS 2.0 was to move it toward Unix like operations, for compatibility with Xenix, it never went all the way. Not in internal workings nor API or shell. MS-DOS is a single user, single Process OS - with a few 'handmade' exceptions like TSR.




        For instance the pipe() command from unistd.h isn't present in BorlandC, which I'm using.




        UNISTD is a POSIX definition. DOS isn't a POSIX system. POSIX definitions where made years after DOS got unix alike features.



        DOS implements STDIN/OUT/ERR. They are made as simple file handles (0,1,2) to be read from/writen to and inherited from the parent program.




        Can anyone tell me how to to this? Preferably in C or Batch.




        Just use redirection one the command line in the usual way via </|/>




        Also, how to pipe stdin/out from the current shell (command.com or 4dos.com) in order to "Skin" the console?




        You might get a hard time, as DOS can only run a single single program at a time. Without two concurent processes it's just not possible to transfer data between tehm.



        Workings of Rediection in DOS



        When pipeing (redirection to a program) is used, all output of the first program to STDOUT gets writen into a temporary file until the program terminates. Then the next program gets started (after the first is unloaded) and the file written is assigned to STDIN (and deleted when this program terminates).



        It is of course is different when devices are used. Here access is immediate and concurent.



        So unless you spread your programs across mutiple DOS machines, you can't come close to unix behaviour (*1).





        I'm working on a retro project and was trying to create a pipe of stdin/out/err in DOS, but I can't find any functions to to this?




        See, that's the true lesson of retrocomputing: these old machines and OSes were not the same as today, just in small, slow and with blocky graphics, they where different. And not just between today and back then, but as well between different manufactures and even machines. Backporting ideas isn't about finding the same function, but to work from a complete different angle.



        Discovering unknown space with different laws of physic :))




        Now, having said all of this and taking the assumption of adding bells and whistles to STDOUT), a clean way to do this would be writing a character driver and assign them as STDIN/OUT when starting command.com. If the driver is (for example) named skinner.dev and the resulting device would be SKINNER, then config.sys needs to contain these lines (2):



        DEVICE=C:DRIVERSKINNER.DEV
        SHELL=C:COMMAND.COM SKINNER


        And from there on, all output to STDOUT is delivered thru your driver - unless redirected that is. Now you may add any kind of framing skins or whatsoever. Keep in mind that the Application might not be aware of and for example still assume a 24x80 screen, even if you took some characters off for a beautiful frame. Similar any output bypassing STDOUT, like when using BIOS calls or direkt screen manipulation, may show up at the wrong place (*3). Last but not least, every program opening CON on its own will as well bypass your driver.



        A few points to think about may be:



        • Don't forget to make the driver as well handling read requests, as Command.Com requires both ways to go thru the same device.


        • You may as well try to replace the build-in CON driver(*4), this means setting the CON bit in the device attributes word as well as replacing/capturing INT 29h, as DOS does handle CON a bit different. (*5)


        • Adding I/O-Control support would support a clean interface to set the workings during runtime (changing colours or whatsoever it does) with a configuration command supplied by you.


        • Do your users a favour and use Assembly - at least for the driver.


        Device drivers can be a lot of fun and are usually way less complicated to write then people tend to assume.



        Caveat: Some mechanics only work with DOS 3.1 and higher even thoug already defined before. This goes especially for monitoring open/close calls.




        *1 - And even then you may need some file server allowing read while write and plunge in a zillion FLUSH calls to make each output seen.



        *2 - For test purpose it may be more appropriate to only load the driver and use redirected STDIN/OUT only via a sub-shell.



        *3 - Some of this may be captured by the driver due manipulation of BIOS data and alike - but that will as well lead to a slow creep into machine and OS dependence while at the same time bloating code ever more.



        *4 - This would remove some of the possible ways to screw up things for child processes in complex scenarios involving sub-shells as well as redirections with the explicit use of CON. On the down side, you'd have to rewrite all of it's functionality - hopefully compatible with ANSI.SYS which already is one.



        *5 - Which BTW would be the better way (when going this route) - get the source for some ANSI.SYS compatible driver like NANSI.SYS and tweek it to support your additional functionality - more work than writing your own, but for sure a great drop in by naming it ANSI.SYS and copying it onto any machine available - not other change needed.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 3 hours ago

























        answered 8 hours ago









        RaffzahnRaffzahn

        55.6k6136224




        55.6k6136224




















            Dacobi is a new contributor. Be nice, and check out our Code of Conduct.









            draft saved

            draft discarded


















            Dacobi is a new contributor. Be nice, and check out our Code of Conduct.












            Dacobi is a new contributor. Be nice, and check out our Code of Conduct.











            Dacobi is a new contributor. Be nice, and check out our Code of Conduct.














            Thanks for contributing an answer to Retrocomputing Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fretrocomputing.stackexchange.com%2fquestions%2f9609%2fdos-create-pipe-for-stdin-stdout-of-command-comor-4dos-com-in-c-or-batch%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

            Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

            Ласкавець круглолистий Зміст Опис | Поширення | Галерея | Примітки | Посилання | Навігаційне меню58171138361-22960890446Bupleurum rotundifoliumEuro+Med PlantbasePlants of the World Online — Kew ScienceGermplasm Resources Information Network (GRIN)Ласкавецькн. VI : Літери Ком — Левиправивши або дописавши її