I have got this little python3 script test.py:
import sys
print('test1')
test1 = sys.stdin.read()
print('test2')
test2 = sys.stdin.read()
print(test1)
print(test2)
And I would like to run this script remotely via ssh like this:
ssh srvid 'cd; python3 test.py'
I would expect that program prints test1, then will wait for input, and then prints test2 and again wait for input.
But the behaviour is slightly different:
ssh srvid 'cd; python3 test.py'
hell
test1
test2
hell
The program first waited for input. I have entered hell and pressed enter and then ctr+d for eof. Script did not wait for second input, and printed out test1 and test2.
It seems, that stdin / stdout are somehow blocked.
I tried same example in bash:
#!/bin/bash
echo "Hello world";
read test;
echo "helloworld 2";
read test2;
echo $test;
echo $test2;
When I invoked this script via ssh, everything worked as I am expecting.
Can somebody help me?
ssh -t host 'command'? – Zoredache Sep 30 '11 at 21:34-tforces pty allocation. – MikeyB Oct 1 '11 at 0:18