Search code examples
bashshellraspberry-pirfidraspberry-pi2

Start a Shell Script on Raspberry with an RFID Tag


I am writing a Cash-System for a small Cafe, using a Raspberry 2 (Raspbian OS), a Touchscreen and an RFID Reader.

I want to get completely rid of a keyboard and mouse. So all user interactions have to happen with touchscreen or RFID. Every employee has its own RFID chip and should be able to start the Cashsystem from console (without having to type "sh start_cash.sh" oslt.

The Raspberry starts directly to a bash without password oslt. The cashsystem is written in JavaFX (so no X Server is permitted). When I place the RFID over the reader, the tagnumber+enter is written onto the console, which seems pretty handy here. But I cannot manage to write a shellscript with the name of the rfid number, which then starts, without typing a "sh" before the rfid number (which is not possible without a keyboard).

So lets assume: I have two different rfid tags (1 and 2) and two different shellscripts (A and B). What do I need to do, that rfid 1 starts script A and rfid 2 starts script B?


Solution

  • case statement

    case $rfidID in
         RFIDTAG1) 
            ./employeeA.sh
            ;;
         RFIDTAG2)
            ./employeeB.sh
            ;;
          *)
            echo "Employee ID not found"
            ;;
    esac
    

    but if you have a lot of employees maybe this will be more efficient?

    #!/bin/sh
    
    echo "Please sign in with Employee ID"
    read rfidemployee
    
    ./Employee$rfidemployee.sh
    

    so essentially you will make a shell script with Employee (or whatever you want to use) and follow it will be there ID number. For example. Employee1234.sh

    then when the employee signs out they re execute script for a employee to log in.