| | |
ssh changes the way python script behaves
![]() |
•
•
Join Date: May 2005
Posts: 215
Reputation:
Solved Threads: 16
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
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
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
why is the flush function needed when I run the script directly, but not if I ssh into a shell , then run the script
Python Syntax (Toggle Plain Text)
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
Python Syntax (Toggle Plain Text)
ssh root@192.168.1.103 /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
Python Syntax (Toggle Plain Text)
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
In a perfect world exceptions would not be needed.
![]() |
Similar Threads
- What are the .apy files in Python (Python)
- execute python script from shell/Interactive Window (Python)
- "Hosts script: Python" (Python)
- Opening a *.exe with python script? (Python)
- freevo uses python (Python)
Other Threads in the Python Forum
- Previous Thread: File Interactions
- Next Thread: Compiling .py files...
| Thread Tools | Search this Thread |
abrupt ansi anti approximation array assignment avogadro backend beginner binary bluetooth builtin calculator character cmd code converter countpasswordentry curved customdialog dan08 decimals dictionaries dictionary dynamic error examples exe file float format function gnu graphics gui heads homework http ideas import input java launcher leftmouse line linux list lists loop module mouse mysqlquery number numbers output parsing path plugin pointer port prime programming progressbar projects push py2exe pygame pyqt python random recursion schedule scrolledtext sqlite statistics string strings sudokusolver sum table terminal text textarea thread threading time tlapse tricks tuple tutorial twoup ubuntu unicode urllib urllib2 variable wikipedia write wxpython xlib






