Giter VIP home page Giter VIP logo

Comments (7)

matthewsheeran avatar matthewsheeran commented on July 2, 2024

I noticed that the stdin Write and WriteLine are missing form the package that are in the original StackOverflow ConsoleAppManager example code which I can try. I was also using "cmd.exe /c ""...\python.exe" -c ... 2>&1"" to merge stderr with stdout. I also discovered from another posting that my Writes may not have been getting through the Python process - which is just what i appeared to be seeing - so I can try it again without cmd.exe as I no lomnger need it and using either of your code bases modified again.

I am still curious though as why you dropped the stdin Write functionaltiy from your final codebase.

If I get it woking I can contribute as I will be doing quite alot of Python script processing..

from consoleapplauncher.

matthewsheeran avatar matthewsheeran commented on July 2, 2024

Nope I have had no joy either with MinGW or GnuWin32 "cat.exe" WriteLine or Write and I pretty that the ConsoleAppManager is doing the right thing thread-wise but it just doesnt get through or may depend upon the nature of the getch() type calls in python.exe cat.exe notepad.exe etc.

I even tried notepad.exe..

Nobody else is doing it and it aint happening for me so I think it may be a case of writing my python scripts out to temp and invoking them as arguments unfortunately as I can't use IronPython and the DLR ScriptRuntime/Engine/Scope/Code instead etc for the reasons i mentioned otherwise i would indeed.

Regards.

from consoleapplauncher.

slavagu avatar slavagu commented on July 2, 2024

Supplying input redirect parameters doesn't work with Process.Start for some reason so the only option I can think of is exposing Write/WriteLine on StandardInput. You will then be able to call app.WiteLine(...) to provide input to your console application. I can add Write/WriteLine to ConsoleApp if that will help.

from consoleapplauncher.

matthewsheeran avatar matthewsheeran commented on July 2, 2024

I tried it with my own code and the ConsoleAppManager similar to yours from here and attached: https://stackoverflow.com/questions/21848271/redirecting-standard-input-of-console-application

ConsoleAppManager.cs.txt

Still no joy with C python.exe cat.exe's notepad.exe etc.

If you put it in I will try it again and tell you if it works but for now I am keeping my same API with a "#filename" as first input row which I then write as a Temp filename and execute the command with the file on disk as the last parameter something much like a bash SheBang if it exists and the code is trvial. Works like a charm and hides this file action code under the API so I can change the former code later without touching the API if I ever get stdin redirection truly working but I do have the feeling that it may indeed be more trouble than it is worth.

The only hint to the problem and solution I have found is here: https://stackoverflow.com/questions/9506606/console-input-redirect

So if I really want to pursue as an answered stated it may be case of looking into C++ code here for this: https://sourceforge.net/projects/console/

Which I am not going to pursue just at the moment as I have my interim solution and I can random overwrite with chars to the same Temp file length before deleting if I wish to secure my scripts.

But do let me know if you put Write/WriteLine in and I will test again. This seems like a must have if one truly wants to encapsulate Async Console App functionality such as in your solution. It is frustating and annoying to have to resort to a hack without fixing it however elegant my "#filename" (which is quite general for any app with file parameter and not only Python BTW) hack might be for now and I can help you to improve ConsoleApp and expand its user base as there is nothing out there that does input redirection sucessfully other than full replacement shells internally like that above to look into. :-)

Kindest Regards.

from consoleapplauncher.

matthewsheeran avatar matthewsheeran commented on July 2, 2024

You could use a generated random Temp filename instead of the "#filename.py" first line and hide the effective pseudo-redirected stdin to disk file entirely (as far as the API is concerned it would appear as a string stdin) but I prefer to use the namimg for easier debugging disabling its overwrite and deletion and being able to find the file created in Temp by name for now! Only an issue if an when I actually have multiple windows/threads doing the same #filename.py Python processing at the same time for now!

from consoleapplauncher.

matthewsheeran avatar matthewsheeran commented on July 2, 2024

Supplying input redirect parameters doesn't work with Process.Start for some reason so the only option I > can think of is exposing Write/WriteLine on StandardInput. You will then be able to call app.WiteLine(...) > to provide input to your console application. I can add Write/WriteLine to ConsoleApp if that will help.

Please do add so I can ditch the ConsoleAppManager code and revist your Writes from ConsoleApp you can basically copy their Write/WriteLine code into yours for now.

Thanks.

from consoleapplauncher.

slavagu avatar slavagu commented on July 2, 2024

I've added support for Write and WriteLine, see usage example in should_get_input_redirect() test. New package published to nuget.org, hope this helps.

from consoleapplauncher.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.