0

I will provide a video to show you as well what is going on, here is the link to the video displaying this strange issue:

https://www.youtube.com/watch?v=o9RUR7t18NA&list=UU0OG8tltECja7Sgxa9A5Drg

The source code is uploaded to pastebin which you can find on the youtube channel but is not really relevant since it is really only the "shutdown" function that is going crazy.

I'd like to address this strange issue or bug.

To narrow things down here is some information: I am using Windows 7 32bit version and am running Python 3.4 also 32bit version.

import os
os.system("shutdown -s -t 60")

The code here is simple and should work, now get this:

If I run this code in the standard Python GUI, it works as intended. However if I run this very same code in IDLE all it does is open up the Command Prompt (cmd) and creates a infinite loop, my only option being to press enter.

Another interesting thing to note is when I try to close this command prompt, the command prompt prints something like this out:

^C ^C ^C ^C ^C ^C

and at times this:

^^^^^^^^^^^^^^^^^^^^C

Is this known? Is there a work around? I need to be able to access this function and it needs to work for my project (A simple shutdown program where the user can input time and in that given time the computer will log off, shutdown etc).

Cœur
  • 37,241
  • 25
  • 195
  • 267
XallZall
  • 281
  • 1
  • 3
  • 5
  • are you sure it isn't `os.system("shutdown -s -t 60")` (no spaces between the minus and the letter) – Antonio Ragagnin Jul 28 '14 at 11:14
  • You are correct that I should not have used the spaces but in my actual project it is written correctly. I corrected this mistake in the post now. – XallZall Jul 28 '14 at 11:21
  • Then delete your question... – martineau Jul 28 '14 at 13:14
  • 1
    Should I not keep it for others to see that this type of error can happen? It can provide information for a possible debug and might help others to see that others might have this issue as well and the way that I fixed it was to redo the code several times. I think this could be useful for somebody. Might change the title to solved but it really is not 100%ly solved. If you really think this cannot help or any moderators then I will remove it. It is a pretty "unique" problem... – XallZall Jul 28 '14 at 13:24

2 Answers2

1

Solution by OP.

My program was called "shutdown", and it seems that the os.system("shutdown -s - t 60") Actually REOPENED the program, rather then executing the shutdown command.

The solution was to rename the program to something else.

Cœur
  • 37,241
  • 25
  • 195
  • 267
0
os.system("C:\Windows\System32\shutdown.exe -s -t 60")

should do. (explicitely run the shutdown.exe from Windows System folder)

Stephan
  • 53,940
  • 10
  • 58
  • 91