EOFError when typing () after printing () in SSH console
I have strange behavior in my Python code. It works fine on my windows console.
For example,
@ cmd.exe: python file.py
File.py file content
print("-------------------------- RANDOM STRING HERE! --------------------------------")
email = input()
print("-------------------------- RANDOM STRING HERE! --------------------------------")
name = input()
print("-------------------------- RANDOM STRING HERE! --------------------------------")
address = input()
print("-------------------------- RANDOM STRING HERE! --------------------------------")
print(email+name+address)
This same code doesn't work when I do:
curl ://filepath/file.py | sudo python3
in the console under SSH. I've already tried with PuTTY and Git Bash, but I still get the same error.
EOFError in SSH console:
I've already tried using sys.stdin, but it doesn't work as expected.
+3
source to share
1 answer
No, really, you cannot do that. Running
... | sudo python3
puts the script in stdin
, so you can't use stdin
from that script anymore .
But you can do it the other way around, without a pipe, using a temporary file:
curl ://filepath/file.py -o /tmp/script
sudo python3 /tmp/script
Or using process replacement (in Bash):
python3 <(curl ://filepath/file.py)
+2
source to share