Develop program in Linux to input and output Windows files?


  1. Posts : 1,778
    Windows 10 Pro
       #1

    Develop program in Linux to input and output Windows files?


    Long story short I want to write a program under a compiler that is available only in Linux, but will operate on Windows files as both input and output. How should I do this? Even though I used to use UNIX many, many moons ago so I know basic UNIX concepts, assume that I'm a Linux newbie.

    Is it better to run this compiler under Windows Subsystem for Linux (the version that maintains Windows files compatibility) or in a separate Linux partition?

    What about the different newline conventions between Linux and Windows?

    How do I pass a filename parameter in a Linux command line e.g. progfoo inputfiles or progfoor inpufiles outputfiles?

    What other questions should I have asked, but didn't even know enough to realize it?

    Should I be asking this question in a different forum here or on a different website?
      My Computers


  2. Posts : 805
    Windows 7
       #2

    If you don't want to write the actual text conversion, pipe thru dos2unix & unix2dos.
    % cat dos.txt | dos2unix | myprog | unix2dos > new.txt

    Then you can read standard input. After you're more comfortable writing your program, find a native function/lib to skip this step.
      My Computer


  3. Posts : 1,778
    Windows 10 Pro
    Thread Starter
       #3

    garlin said:
    If you don't want to write the actual text conversion, pipe thru dos2unix & unix2dos.
    % cat dos.txt | dos2unix | myprog | unix2dos > new.txt
    Great input. Proof that I need to think of myself as a newbie here.

    Then you can read standard input. After you're more comfortable writing your program, find a native function/lib to skip this step.
    Two questions:

    1. What do you mean by "native function/lib" here?
    2. what if I have multiple input files or output files? What if my input files are existing Windows files?

    3. Actually a third question. Instead of creating a list of programs as input, could I use a regex that defines the folders and the files within that folder?

    I haven't written any software for too many years because my career went in a different direction. (TL;DR) So I'm happy that I now have the time to write software again, even simple programs.
      My Computers


  4. Posts : 805
    Windows 7
       #4

    You didn't mention the compiler language. Many Windows-based languages have some built-in or contributed function to perform UNIX<->DOS conversion, as that's fairly common.

    If you find a CR/LF routine that works for you, then you can tackle argument passing. Most langs have the equivalent to args.

    Another choice is PowerShell which has a lot of high-level routines to do pattern matching on folders & files, and does foreach's in a UNIX-like manner. And it does the expected $args thing.
      My Computer


  5. Posts : 1,778
    Windows 10 Pro
    Thread Starter
       #5

    garlin said:
    You didn't mention the compiler language.
    It's Iron Spring PL/1, running on Linux. Why PL/1? Because that's what I used to use a lot and still remember, plus I have all the original IBM manuals for their PL/1. With PL/1, I can get productive right away. With C++ or Python there is a steep (for me) learning curve. I've done the tutorials, but that's just a start.

    Many Windows-based languages have some built-in or contributed function to perform UNIX<->DOS conversion, as that's fairly common.

    If you find a CR/LF routine that works for you, then you can tackle argument passing. Most langs have the equivalent to args.

    Another choice is PowerShell which has a lot of high-level routines to do pattern matching on folders & files, and does foreach's in a UNIX-like manner. And it does the expected $args thing.
    Same issues with PowerShell vs. ordinary regex. I know regex, but not PowerShell.
      My Computers


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 12:30.
Find Us




Windows 10 Forums