#! /bin/sh # # roku-remote-v4.sh # Roku Remote Controller Script version 4, written in Bash # # Released March 15, 2014. # # # The author of the original versions of this Roku remote controller script is # "JM", also known as "Fubaya". # # http://a-more-common-hades.blogspot.com/2011/07/final-roku-bash-shell-script.html # http://a-more-common-hades.blogspot.com/2011/07/bash-script-to-control-roku.html # # http://a-more-common-hades.blogspot.com/ # # Thank you very much to "JM"/"Fubaya" for creating such useful scripts and such # a useful blog! # # # I, Apollia of Astroblahhh.Com, modified the script at the first link above a lot # to make this new version. # # http://astroblahhh.com/software/bash/roku-remote-control-script/v4/roku-remote-v4.zip # # # A web-viewable copy of this script: # # http://astroblahhh.com/software/bash/roku-remote-control-script/v4/roku-remote-v4.txt # # # Web-viewable copies of some small companion scripts (all included in the zip file): # # http://astroblahhh.com/software/bash/roku-remote-control-script/v4/Launch-Netflix-Channel-12--perl.txt # http://astroblahhh.com/software/bash/roku-remote-control-script/v4/Launch-Netflix-Channel-12--bash.txt # http://astroblahhh.com/software/bash/roku-remote-control-script/v4/Launch-Roku-Remote-Control-Script-Live-Mode-in-an-RXVT-Terminal-Window--perl.txt # http://astroblahhh.com/software/bash/roku-remote-control-script/v4/Launch-Roku-Remote-Control-Script-Live-Mode-in-an-RXVT-Terminal-Window--bash.txt # # # Most comments are by me, Apollia, unless otherwise specified. # # http://astroblahhh.com/ # # ############################################################################################ # # # How to Make the Script Useable # # First, I apologize in advance for anything that is wrong with this # script. # # It works well for me overall so far, but, I haven't tried it with # anything but Lucid Puppy Linux 5.2.8 and my Roku XS. # # And, I did run into a significant problem which I'm not sure how to # fix - see the warning below. # # I am able to mostly avoid the problem with my set-up, but, I'm afraid # it (or something else) might pop up for people with different systems. # # So, please only use this script at your own risk. # # # To make this script useable, put your Roku's IP address in the # section of code titled "Some settings you can change". # # Hopefully that will be the only thing you'll need to change. # # ############################################################################################ # # # How to Run the Script # # You can run this script's "live" mode from a terminal prompt by typing: # # sh roku-remote-v4.sh live # # # ********** WARNING ********** # # Warning: don't run this script in "live" mode unless you're running it # inside a terminal window! # # I don't know why, but, running this script in "live" mode without a # terminal window makes my Roku go crazy, as if my Roku is being sent a # lot of commands (not sure what), non-stop, until the script's process # is killed. # # Sorry, I don't know how to fix that problem with "live" mode - so, I can # only advise you not to do anything to start "live" mode without this # script running inside a terminal window. # # ********** END OF WARNING ********** # # # The zip file includes some small scripts which are intended to launch this # script's "live" mode (hopefully safely) in a terminal window. However, # those little scripts assume you have the RXVT terminal software, which is # installed by default in many Puppy Linuxes. # # If your Linux doesn't have RXVT, the "live" mode launch scripts hopefully # won't do anything. # # But, if you're using Lucid Puppy 5.2.8 or a similar Puppy Linux with RXVT, # then, you can conveniently (and hopefully safely) launch "live" mode # inside an RXVT window without typing a terminal command by clicking on one # of the launcher scripts. # # The scripts which launch Netflix should hopefully work in any Linux, but # are also untested with anything but Lucid Puppy 5.2.8. # # # You can give this script any typeable commands from the terminal prompt, # such as: # # sh roku-remote-v4.sh mu home go 12 # sh roku-remote-v4.sh string star trek # # If you run the script that way, the script will just run the commands you # gave, then end. # # ############################################################################################ # # # Hotkeys and Commands # # The script will display help text if you press the F12 key on your keyboard, # or type "help", "hel" or "he". # # Every hotkey and command is summarized there. # # But, the below explains things more verbosely than the built-in help text. # # # Note: The Back button, Info button, Instant Replay button, and A and B # buttons don't exist on old-style Roku controllers. Don't know if they # work with old Rokus. # # I didn't know how to add the A and B buttons (used for games). # # # Key on your keyboard Equivalent Roku Controller Button #-------------------------------------------------------------------------------- # | # Arrow Keys | The arrow buttons # (Up, Down, Left, Right) | (Up, Down, Left, Right) #-------------------------------------------------------------------------------- # Esc | Back button # | (Looks like a left arrow, but, isn't the # | same thing as the left arrow button.) #-------------------------------------------------------------------------------- # F1 | Info button # | (Looks like an asterisk: * ) #-------------------------------------------------------------------------------- # F3 | Nonexistent Search button #-------------------------------------------------------------------------------- # F4 | Nonexistent Enter button # | (For quickly submitting the data in # | text entry fields, like search forms.) #-------------------------------------------------------------------------------- # F5 | Instant Replay button # | (A circular arrow going left then down.) #-------------------------------------------------------------------------------- # Enter key by itself | Select button # | (The button that reads either "Select" # | or "OK".) #-------------------------------------------------------------------------------- # F9 | Reverse Scan (rewind) button #-------------------------------------------------------------------------------- # F10 | Play/Pause button #-------------------------------------------------------------------------------- # F11 | Forward Scan (fast-forward) button #-------------------------------------------------------------------------------- # # # Other hotkeys - just functions of this script with no equivalent Roku buttons: # # F2 - Go to dev channel (useful if you uploaded some software to your Roku). # # F7 - List channels. # # F8 - Repeat previous valid command. # # F12 - Display help for this script. # # # A link with info about valid Roku buttons, including the ones that don't # yet exist on any physical Roku controller (Search and Enter): # # http://sdkdocs.roku.com/display/sdkdoc/External+Control+Guide#ExternalControlGuide-34ValidKeys # # # Some Roku channels have a Search screen which you might be able to reach by # pressing the F3 key on your keyboard, or typing "fi", "find", or "search". # # (The Netflix app has a Search screen, but you can only reach it if you're on the # first page of the Netflix app.) # # If you use the typed "fi"/"find"/"search" commands, you can optionally put some # text to search for after them, like: # # find Star Trek # # The command just inputs the text without submitting the search form. To # submit the search form, you can press the F4 hotkey, or type "en", "ent", # or "enter". # # # The "ss"/"submitstring"/"submitsearch" command, followed by any string of # text, both inputs text and submits the search form (or other text input # form) by sending an "Enter" button press. # # If you want to input some text without the form being submitted, you can # use the "st" (or "str" or "string") command, followed by any string of text. # # # You can delete text by using the "bs" (backspace) command, optionally followed # by a number. # # For example... # # bs 5 # # ...will delete 5 characters. # # # Or, "bx" will quickly delete 20 characters (or whatever number the variable # "number_of_backspaces_for_bx_command_to_do" is set to). # # # To enter multiple commands, use the "mu" command (short for "multiple commands") # followed by whatever commands you want, separated by spaces. # # If you need to wait for the Roku to load something before you can keep issuing # commands, you can use the "wait" command, followed by a number of seconds to # wait. # # For example: # # mu home go 12 wait 10 right right play # # This goes to the home Roku screen, then goes to channel 12 (Netflix on my Roku). # Then, since Netflix takes a while to get going, a "wait" command is needed so # the last three commands - "right", "right", and "play" - won't get lost. # # After the 10-second wait, the cursor is moved right twice, then whatever is # under the cursor at that point is played. # # # Another "mu" example: # # mu home go 12 wait 10 find "star trek" # # This goes to Netflix, waits 10 seconds, then goes to Netflix's search page, then # inputs the string "star trek" (without quotes). # # (When using the "mu" command, search strings with spaces need quotes around them - # otherwise everything after "star" would have been interpreted as a command.) # # # To repeat a command (or even a series of commands sent by "mu"), you can press the # F8 key on your keyboard, or type "gg". # # ############################################################################################ # # # My other modifications to this script were relatively minor. I added whitespace # to make the script more readable, and many informative comments. # # And, if a command isn't understood, the script now tells you. # # # My (Apollia's) personal website: # # http://astroblahhh.com/ # # # Here's the blog of "JM", also known as "Fubaya", who is the author of the # original versions of this script: # # http://a-more-common-hades.blogspot.com/ # # # Below, the script begins. # ############################################################################################ #################################### # # Some settings you can change # # ip= # Please insert your Roku's IP address above. # # (Just don't put spaces around the equal sign - Bash gets confused by that.) # # # You can find your Roku's IP address by going to your Roku's Settings # menu, selecting About, then pressing the right arrow. # # The IP address will probably look something like this: 192.168.1.3 # # # If you put in your Roku's IP address and this script still doesn't work, # perhaps your computer and Roku aren't connected to the same network? # # Or, maybe there's some other problem. #ip=192.168.1.3 sleep_length_for_mu_commands=.09; # In seconds. sleep_length_for_string_input=.15; # In seconds. If it's losing characters, try a slower speed. number_of_backspaces_for_bx_command_to_do=20; command_prompt="Roku > "; # Here, you can make the command prompt look like whatever you want. previous_valid_input="none yet"; # Default: "none yet" # # If you want to make the "gg" command (triggered by the F8 hotkey) # capable of doing something even immediately after the script is # launched, you can put commands above. #previous_valid_input="none yet"; # # # End of some settings you can change. # # Nothing below this point needs to be modified. # ######################################################################## version_number=4; ######################################################################## # # # Next, 4 functions get defined before anything else happens. # # Then, Start_Taking_Input() gets executed. # # # (Bash gets confused if you try to execute functions anywhere before # the place where they're defined.) ########################################## # # # Start of function # # # Start_Taking_Input() # # Start_Taking_Input() { if [ "$1" = "" ] # Originally, I mistakenly thought thought running this script in "live" mode # without a terminal window would be harmless. But when I actually tried # that, my Roku went crazy until I killed this script's process. # # So, this part prevents the script from running if there are no parameters. then exit; # If the script is launched with the parameter "live", the script enters "live" # mode, which gives you a command prompt that immediately reacts to various # keystrokes. # # Warning: Don't enter "live" mode unless you're running this script in a # terminal window! It might make your Roku go crazy until you kill this script's # process. elif [ "$1" = "live" ] then echo "Roku Remote Controller Script version $version_number, written in Bash."; echo ""; echo "To end this script, close the window, or type \"exit\" or \"quit\" or \"qu\"."; echo ""; echo "For help, press the F12 key, or type \"help\" or \"he\"." echo ""; echo ""; echo -n "Roku IP address: "; if [ "$ip" = "" ] then echo "Not yet set, so this script won't work yet!"; echo ""; echo "Please add the Roku's IP address to this script's source code."; echo ""; echo -n "Please open this script in a text editor to do that, and to read more instructions."; else echo -n "$ip"; fi echo ""; echo ""; echo ""; while [ "$input" != "exit" ] do echo -n "$command_prompt"; IFS="|" # Changes the delimiter of the read command, to make it possible # below to distinguish between spaces and newlines. while read -sN1 key # 1 char (not delimiter), silent do # Had to do a bunch of goofy crap to get the script to be able to # properly understand keystrokes and respond to them immediately. # # There might be a simpler, more elegant way to do it, but, this # works well enough, so for me, it's not worth the trouble to # perfect it. k1=""; k2=""; k3=""; k4=""; k5=""; # Used (and modified) code from here: # http://stackoverflow.com/questions/10679188/casing-arrow-keys-in-bash # [Comment not by Apollia - instead, from Stack Overflow:] # # catch multi-char special key sequences read -sN1 -t 0.0001 k1 read -sN1 -t 0.0001 k2 read -sN1 -t 0.0001 k3 read -sN1 -t 0.0001 k4 read -sN1 -t 0.0001 k5 key+=${k1}${k2}${k3}${k4}${k5} # This page helped - # # http://stackoverflow.com/questions/13224142/how-to-set-read-for-different-characters-in-bash-shell case "$key" in # First, all the hotkeys that send commands # to the Roku immediately. $'\e') # Esc key echo " Back"; input="back"; break; ;; $'\e[11~') # F1 key echo " Info"; input="info"; break; ;; $'\x1b[12~') # F2 key echo " Dev Channel"; input="go dev"; break; ;; $'\e[13~') # F3 key echo " Search"; input="search"; break; ;; $'\x1b[14~') # F4 key echo " Enter"; input="enter"; break; ;; $'\x1b[15~') # F5 key echo " Instant Replay"; input="instantreplay"; break; ;; $'\x1b[18~') # F7 key echo " Channels"; input="channels"; break; ;; $'\x1b[19~') # F8 key - repeat previous valid command input="gg"; break; ;; $'\x1b[20~') # F9 key echo " Reverse Scan (Rewind)"; input="rev"; break; ;; $'\x1b[21~') # F10 key echo " Play/Pause"; input="play"; break; ;; $'\x1b[23~') # F11 key echo " Forward Scan (Fast-Forward)"; input="fwd"; break; ;; $'\x1b[24~') # F12 key #echo "Help"; input="help"; break; ;; $'\e[A'|$'\e0A') # Up arrow key echo " up" input="up" break ;; $'\e[D'|$'\e0D') # Left arrow key echo " left" input="left" break ;; $'\e[B'|$'\e0B') # Down arrow key echo " down" input="down" break ;; $'\e[C'|$'\e0C') # Right arrow key echo " right"; input="right" break ;; $'\x1b\x5b\x31\x7e') # Home_key_num_7 # # Key code found here: # http://www.tldp.org/LDP/abs/html/escapingsection.html echo " Home"; input="home"; break; ;; $'\n') # Enter/return key echo ""; break; ;; # End of hotkeys that send commands to the # Roku immediately. # Start of non-hotkeys. # # I had to go to a bit of trouble to make it look like the # script was providing a normal command prompt for these. # # I had to make the script redraw the command line every # time backspace is pressed. $'\177') # Backspace key input=`echo $input|head -c -2`; echo -e -n "\r\033[K$command_prompt$input"; ;; *) # This *) case catches any other input. input=$input$key echo -n "$key"; # This line unnecessarily redraws the whole command line: # # echo -e -n "\r\033[K$command_prompt$input"; # This page helped - # http://stackoverflow.com/questions/2388090/how-to-delete-and-replace-last-line-in-the-terminal-using-bash ;; esac done # End of while loop. if [ "$input" = "" ] # ...then the user pressed enter and nothing else. then echo "Select"; input="select"; fi goto=${input#* }; # I don't even know what this means, so I'm just leaving it alone. Parse_Input input=""; done # End of while loop. else # To handle any other parameters (other than "live" or nothing) # this script was launched with... IFS=" "; read command commandless_args <<< "$@"; # This splits things up usefully, and trims whitespace. input="$command $commandless_args"; goto="$command $commandless_args"; read input <<< "$input"; # Trims whitespace which otherwise would confuse the parser. IFS="|" Parse_Input; fi } # # # End of function # # Start_Taking_Input() # ########################################################### ########################################## # # # Start of function # # # Input_String_of_Chars() # # Input_String_of_Chars() { # The function that handles the "st"/"str"/"string" string input command, # the "ss"/"submitstring" string input+Enter command, as well as the # "find"/"fi"/"search" command if it's used with an optional search string. string=$1; IFS=" "; # http://www.cyberciti.biz/faq/unix-linux-bash-while-read-function-define-ifs-delimiter/ # # IFS stands for internal field separator. Here, it helps determine how the # rather confusingly-named "read" command will break the string into separate # portions, kind of like the "explode" command in PHP. I guess the IFS is # basically equivalent to the delimiter in the PHP "explode" command. read command commandless_string <<< "$string"; length_of_string=${#commandless_string}; char_arrin=0; # Arrin is short for ARRay INdex. sleep $sleep_length_for_string_input; while [ $char_arrin -lt $length_of_string ] do input="${commandless_string:$char_arrin:1}"; if [ "$input" = "\"" ] # Skips quotes. then ((char_arrin++)) continue fi Parse_Input; sleep $sleep_length_for_string_input; ((char_arrin++)) done if [ $length_of_string -gt 0 ] then echo "Done inserting string!"; fi IFS="|"; } # # # End of function # # Input_String_of_Chars() # ########################################################### ########################################## # # # Start of function # # # Process_Multiple_Commands() # # Process_Multiple_Commands() { # The function that handles the "mu" command for executing multiple commands. input=$1; IFS=" "; read mu muless_commands <<< "$input"; IFS=";"; # http://stackoverflow.com/questions/10586153/bash-split-string-into-array read -a array_of_commands <<< "$muless_commands"; IFS=" "; for element in "${array_of_commands[@]}" do goto=""; read -a fragmentized_element <<< "$element"; fragment_arrin=0; # Arrin is short for ARRay INdex. count_of_fragmentized_elements=${#fragmentized_element[@]}; while [ $fragment_arrin -lt $count_of_fragmentized_elements ] do arrin_after_current_fragment_arrin=$fragment_arrin+1; case "${fragmentized_element[fragment_arrin]}" in "go") goto="go ${fragmentized_element[$arrin_after_current_fragment_arrin]}"; input="$goto"; ((fragment_arrin++)) ;; "wait") input="wait ${fragmentized_element[$arrin_after_current_fragment_arrin]}"; ((fragment_arrin++)) ;; "bs"|"del"|"backspace") input="backspace ${fragmentized_element[$arrin_after_current_fragment_arrin]}"; ((fragment_arrin++)) ;; "fi"|"find"|"search"|"st"|"str"|"string"|"ss"|"submitstring"|"submitsearch") command="${fragmentized_element[fragment_arrin]}"; inputstring=${fragmentized_element[$arrin_after_current_fragment_arrin]}; ((fragment_arrin++)) if [[ "$inputstring" = *"\""* ]] then ((fragment_arrin++)) while [ $fragment_arrin -lt $count_of_fragmentized_elements ] do inputstring="$inputstring ${fragmentized_element[$fragment_arrin]}"; if [[ "${fragmentized_element[$fragment_arrin]}" = *"\""* ]] then break fi ((fragment_arrin++)) done fi case "$command" in "fi"|"find"|"search") input="find $inputstring"; ;; "st"|"str"|"string") input="string $inputstring"; ;; "ss"|"submitstring"|"submitsearch") input="submitstring $inputstring"; ;; esac ;; *) input=${fragmentized_element[$fragment_arrin]}; ;; esac echo "Mu command: $input"; Parse_Input "don't update previous valid input"; sleep $sleep_length_for_mu_commands; ((fragment_arrin++)) done done IFS="|"; } # # # End of function # # Process_Multiple_Commands() # ########################################################### ########################################## # # # # Start of function # # # Display_Help() # # Display_Help() { echo ""; echo " ------- Help -------"; echo ""; echo " Hotkeys which instantly command the Roku:"; echo ""; echo "Arrow keys - Up, Down, Left, Right"; echo ""; echo "F1: Info F3: Search F5: Instant Replay"; echo "F9 Rewind F10 Play/Pause F11 Fast-Forward"; echo ""; echo "F2 Go to dev channel F4: Enter (shortcut for submitting text input in a form)"; echo "Esc: Back Home: Home F7: List Channels"; echo "F8: Repeat command F12: Help"; echo ""; echo ""; echo " Typeable commands:"; echo ""; echo "apps|app|ap|channels|channel|ch - Lists all installed Roku channels in a format like 12 Netflix."; echo ""; echo "go [number, or text such as 'dev'] - Go instantly to a Roku channel."; echo ""; echo ""; echo "search|find|fi [optional search string] - Go to search page of channel, and optionally search for the text you provided. Doesn't automatically submit the search form, so, press the F4 hotkey to submit it, or type \"enter\", \"ent\" or \"en\"."; echo ""; echo "ss|submitstring|submitsearch [string] - Inserts a string of text, then submits the text input form, so you won't have to press F4 or type \"enter\" afterward."; echo ""; echo "st|str|string [string] - Insert a string of text, without submitting the text input form."; echo ""; echo ""; echo "bs|del [optional number] - Do backspace(s). wake - Just does a backspace."; echo ""; echo "bx - Does $number_of_backspaces_for_bx_command_to_do backspaces."; echo ""; echo ""; echo "mu [plus a list of whatever commands you want] - Execute multiple commands. (Text strings with spaces should be enclosed in quotes.)"; echo ""; echo "wait [number of seconds] - Sometimes useful when using the 'mu' command, in case you have to wait for something to load before executing the next commands."; echo ""; echo "gg - Repeat the last valid command (other than gg)."; echo ""; echo ""; echo "help|hel|he - Display this help text."; echo ""; echo "exit|quit|qu - Quit this script."; echo ""; } # # # End of function # # Display_Help() # ########################################################### ########################################## # # # Start of function # # # Parse_Input() # # Parse_Input() { optional_parameter=$1; if [ "$optional_parameter" = "don't update previous valid input" ] then should_update_previous_valid_input="no"; else should_update_previous_valid_input="yes"; fi case "$input" in apps|app|ap|channels|channel|ch) # [Comment not by Apollia; instead, by "JM", also known as "Fubaya"]: # # will list all installed apps in this format: 12 Netflix wget -q -O - "http://${ip}:8060/query/apps" | sed -e 's/]*>##g' -e 's/\".*>/ /g' # For unformatted output: # # wget -q -O - "http://${ip}:8060/query/apps" ;; go*) # [Comment not by Apollia - instead, by "JM", also known as "Fubaya"]: # # from the above list, use go plus the number to select channel. # e.g. "go 12" to go to netflix wget -q -O - --post-data "" "http://${ip}:8060/launch/${goto#* }" shift ;; gg) if [ "$previous_valid_input" != "none yet" ] && [ "$previous_valid_input" != "gg" ] then echo "Repeating most recent valid command: $previous_valid_input "; input=$previous_valid_input; Parse_Input; return 0; else if [ "$previous_valid_input" = "none yet" ] then echo "Can't repeat command - no previous input yet."; else echo "Can't repeat the repeat command - and actually the repeat command is never supposed to be recorded as the previous valid input, so this is a glitch!"; fi fi should_update_previous_valid_input="no"; ;; wait*) seconds_to_wait=0; seconds_to_wait="${input//[!0-9.]/}"; if [ "$seconds_to_wait" = "" ] then seconds_to_wait=1; fi echo "Waiting $seconds_to_wait seconds..."; sleep $seconds_to_wait; ;; help|he|hel) Display_Help; ;; mu*) mu_input=$input; Process_Multiple_Commands $input; should_update_previous_valid_input="yes"; input=$mu_input; ;; ss*|submitsearch*|submitstring*) ss_input=$input; Input_String_of_Chars "$input"; wget -q -O - --post-data "" "http://${ip}:8060/keydown/enter" wget -q -O - --post-data "" "http://${ip}:8060/keyup/enter" should_update_previous_valid_input="yes"; input=$ss_input; ;; st*|str*|string*) st_input=$input; Input_String_of_Chars "$input"; should_update_previous_valid_input="yes"; input=$st_input; ;; space|sp|" ") wget -q -O - --post-data "" "http://${ip}:8060/keypress/lit_ " echo "Space inserted!"; ;; home|rev|fwd|play|select|left|right|down|up|back|instantreplay|info) wget -q -O - --post-data "" "http://${ip}:8060/keydown/${input}" wget -q -O - --post-data "" "http://${ip}:8060/keyup/${input}" ;; enter|ent|en) echo "Enter"; wget -q -O - --post-data "" "http://${ip}:8060/keydown/enter" wget -q -O - --post-data "" "http://${ip}:8060/keyup/enter" ;; a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|1|2|3|4|5|6|7|8|9|0) wget -q -O - --post-data "" "http://${ip}:8060/keypress/lit_${input}" ;; backspace*|del*|bs*) quantity_of_backspaces=0; quantity_of_backspaces="${input//[!0-9]/}"; if [ "$quantity_of_backspaces" = "" ] then quantity_of_backspaces=1; fi inc=0; while [ "$inc" -lt "$quantity_of_backspaces" ] do wget -q -O - --post-data "" "http://${ip}:8060/keypress/backspace" ((inc++)) done echo "Did $quantity_of_backspaces backspaces!"; quantity_of_backspaces=0; ;; pause) # Play and pause are the same button on Roku controllers. wget -q -O - --post-data "" "http://${ip}:8060/keydown/play" wget -q -O - --post-data "" "http://${ip}:8060/keyup/play" ;; wake) wget -q -O - --post-data "" "http://${ip}:8060/keypress/backspace" ;; re) wget -q -O - --post-data "" "http://${ip}:8060/keydown/instantreplay" wget -q -O - --post-data "" "http://${ip}:8060/keyup/instantreplay" ;; sel) wget -q -O - --post-data "" "http://${ip}:8060/keydown/select" ;; search*|find*|"fi"*) wget -q -O - --post-data "" "http://${ip}:8060/keydown/search" wget -q -O - --post-data "" "http://${ip}:8060/keyup/search" Input_String_of_Chars "$input"; ;; bx) inc=0; while [ $inc -lt $number_of_backspaces_for_bx_command_to_do ] do wget -q -O - --post-data "" "http://${ip}:8060/keypress/backspace" ((inc++)) done echo "Done doing $number_of_backspaces_for_bx_command_to_do backspaces!"; ;; exit|quit|ex|qu) echo -e "Exiting Roku command script!\n"; input="exit"; exit ;; "") # Just ignoring blank input. ;; *) echo -e "Command not understood! Command: $input\n"; should_update_previous_valid_input="no"; ;; esac if [ "$should_update_previous_valid_input" = "yes" ] then if [ "$input" != "gg" ] then previous_valid_input=$input; fi fi; } # # # End of function # # Parse_Input() # ########################################################### Start_Taking_Input "$@"; # This "$@" is to pass all the script's launch parameters into the Start_Taking_Input() function. # # # End of script # ######################################################################################