0

I have this program in python that reverses a string. Keep in mind that it is only a example. I won't use it for any real world application

while True:
    n = input("Coisa:")
    if n == "ex":
        break
    n = n[::-1]
    print("\n"+n)
print("stoped")

When I try passing an input through a batch file using this script:

echo 1234|myprogram.py
pause

It works in the first input, but than gives an End of file error, because it tries to receive an input but none is passed

Is there a way to pass the first input, than the next input will be done by the user using the keyboard?

I want to now a more general solution. There might way to do this by modifying the program, but it wouldn't work for other programming languages.

Bruno Jambeiro
  • 156
  • 1
  • 9
  • ok, but what is the reason for "semi" automation? if a user is going to type anyway, why not type both? anyway, though I get what you want, you would need to clarify by showing an actual example of how you expect to run it and what you want the result to be. – Gerhard Jul 09 '20 at 14:16
  • once python is reading from pipe, how would you think can stdin be redirected to user input? your logic doesn’t make sense to me – elzooilogico Jul 09 '20 at 14:37
  • I really doesn't think anything. I don't now much about this topic so i am asking if it is possible. I am asking this partially because i am curious about this, but also because the firsts inputs that i want to pass are multiple really long inputs(8000+ characters) – Bruno Jambeiro Jul 09 '20 at 14:56
  • Is this pertinent? https://stackoverflow.com/a/1454400/447901 – lit Jul 09 '20 at 15:45
  • It could be pertinent if i was the one write the program. The program that i am trying to pass the input is the minecraft server program that is Written in java. I what i want to pass is just a bunch of minecraft commands. I image that minecraft being a really popular game there is another way of doing it using a plugin in or something similar, but i decided to ask because i thought if there was a solution for this program it would generalize well for other situations that i might encounter – Bruno Jambeiro Jul 09 '20 at 16:16
  • Please read the Microsoft page [Command prompt (Cmd. exe) command-line string limitation](https://support.microsoft.com/en-us/help/830473/command-prompt-cmd-exe-command-line-string-limitation). It is in general no good idea to pass very long strings via Windows command line to an executable or script. – Mofi Jul 09 '20 at 16:29

0 Answers0