0

I use my pi Model b to turn a pump on and off. It boots to the script and requires an input that it processes. So far it works very well. What I need is to send an input that will get me out of the script but to the command line, now as soon as I send the input to get out of the script it goes to the GUI.

this is the script and it runs on boot as it was added to the .bash_profile. the inittab was edited so as to not require login. When it boots it comes to the 'Amount of litres to be treated? ' and expects an input. When I send '0' I want it to go to the command line (pi@raspberrypi:~$) instead of the GUI that it now goes.

import time

while True:
    Quantity = input('Amount of litres to be treated?   ')

    fuel = float(Quantity) * 0.1269

    sum2 = float(Quantity) * 0.4

    print ('Catalyst to be added= ', sum2)

    print ('Pump ON')

    print ('..................')

    #gpio on time

    #GPIO.output(7,True)

    time.sleep(fuel)

    print ('Pump Off')

    #GPIO.output(7,False)
    if sum2 == 0:
        break
  • Does your Pi boot to the command line or GUI? How are you launching your script on boot? – Steve Robillard Aug 6 '17 at 10:21
  • It boots to the command line Steve (runs that script and expects a numeric input), when i send zero I want it to get out of the script to the command line and not the GUI. – silas Aug 6 '17 at 10:44
  • First, the answers to my question belong in your question, not the comments. Second, you should not be picking and choosing which ones to answer. Please also include in your question the code used to exit your script, because I fail to see how it is exiting to the GUI if your Pi does not boot to the GUI and run your script from the GUI. – Steve Robillard Aug 6 '17 at 10:53
  • My apologies for the mis- or abuse of the comments – silas Aug 6 '17 at 11:24
  • why don't you just exit(0) ? – Liam Aug 6 '17 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.