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
source = "/mnt/samba/%s" %i destination = "/mnt/media/movies" print "copying %s to %s" %(i, destination) shutil.copy2(source, destination)
when I ssh into the freevo box then run the script it behaves like I think it shoud. first it runs the print function, then runs the shutil.copy2 function.
here is where it is behaving buggy. if I run the script directly using a command like this
ssh email@example.com /usr/local/bin/sambacopy.py
it does not print to the screen until after it has finished copying. I have found a solution of using sys.stdout.flush() directly after the print statment
source = "/mnt/samba/%s" %i destination = "/mnt/media/movies" print "copying %s to %s" %(i, destination) sys.stdout.flush() shutil.copy2(source, destination)
why is the flush function needed when I run the script directly, but not if I ssh into a shell , then run the script