![]() |
ssh changes the way python script behaves
I wrote a python script that checks for new media on my windows box, if it is new it copys it over to my standalone freevo jukebox. Below is a small part of the script that does the actually copying
Code:
source = "/mnt/samba/%s" %ihere is where it is behaving buggy. if I run the script directly using a command like this Code:
ssh root@192.168.1.103 /usr/local/bin/sambacopy.pyCode:
source = "/mnt/samba/%s" %i |
I think the reason may be that in your second case, ssh is running the command as a subprocess, rather than through a shell. The upshot is that the output is buffered until the command completes.
Your call to "sys.stdout.flush()" flushes the buffer, so the output is printed immediately. A quick test to see if my guess is correct would be to put this script on your server: Code:
#!/usr/bin/python |
sounds reasonable :-)
|
the script tested as you thought. it waits 10 seconds then prints both to screen. I still do not understand why running the command as a subprocess would cause all of the output not to be flushed until the script finishes.
|
Quote:
Again, I'm really just guessing here though ;) |
| All times are GMT -5. The time now is 06:21 PM. |