-1

Edit the script to use the input() function to query the user for the shutdown timeout period. Edit the script to use another input() function to query the user for a message to display as the machine executes the shutdown. I am having problems using the input function to ask the user for a time to shutdown the computer and also asking them for a message to display.

import os

#chkdsk = "chkdsk C:"
#os.system(chkdsk)

print("How much time till shutdown?")
time = input() 
print (time)

shutdown = 'shutdown", "-f", "-r", "-t", "-c", MESSAGE HERE'
os.system(shutdown)
David Zemens
  • 53,033
  • 11
  • 81
  • 130
BrewCrew15
  • 23
  • 6
  • 3
    *I am having problems using the input function...* What specific problem(s)? (Hint: you should include this information in the question itself, and all future questions you might ask here.) – David Zemens Nov 15 '16 at 20:02
  • http://stackoverflow.com/questions/510348/how-can-i-make-a-time-delay-in-python?rq=1 – David Zemens Nov 15 '16 at 20:03
  • http://stackoverflow.com/questions/5178927/executing-function-at-specified-time?rq=1 – David Zemens Nov 15 '16 at 20:03
  • 1
    FWIW, you should pass the input prompt as an arg to the `input` function rather than using `print`. BTW, you're missing a `"` before `shutdown`. And you shouldn't use `time` as a variable name because that's the name of a standard module. Using it as a variable name makes your code confusing to read. – PM 2Ring Nov 15 '16 at 20:06

2 Answers2

0

Do I understand you correctly: You want to put the time inside the string?

shutdown = 'shutdown -f -r -t {time} -c MESSAGE HERE'
os.system(shutdown.format(time=time))
L3viathan
  • 26,748
  • 2
  • 58
  • 81
  • Yes. I want to ask the user for a time and then insert it in the shutdown command. – BrewCrew15 Nov 15 '16 at 22:39
  • Yes. I tried your code but it still did not execute properly. After entering in the time and message input the help page for shutdown popped up. – BrewCrew15 Nov 15 '16 at 23:06
0

You just have to use that line:

x = int(input("How much time till shutdown?"))
nrhode
  • 913
  • 1
  • 9
  • 27