View Full Version : Shell Scripting Help
rbautch
07-10-2005, 01:40 AM
I've been trying to learn basic shell scripting over the last several days, but the one area I'm having trouble with is setting variables interactively, using the "read" command. For example, a simple script like this:#!/bin/bash
echo -n "Enter your name here : "
read name
echo "your name is = $name"
doesn't seem to take user input when run on either of my Tivos. Whatever is entered doesn't stick, it just gets entered on the next line of bash after the script ends. I've googled for a few hours, but this isn't an easy problem to search for, since the problem is not the script iteself. Any ideas?
eastwind
07-10-2005, 09:02 AM
I've been trying to learn basic shell scripting over the last several days, but the one area I'm having trouble with is setting variables interactively, using the "read" command. For example, a simple script like this:#!/bin/bash
echo -n "Enter your name here : "
read name
echo "your name is = $name"
doesn't seem to take user input when run on either of my Tivos. Whatever is entered doesn't stick, it just gets entered on the next line of bash after the script ends. I've googled for a few hours, but this isn't an easy problem to search for, since the problem is not the script iteself. Any ideas?
I just did a C&P of your code and it worked fine on my DTiVo w/6.2. Maybe you need to give a better example...one that doesn't work. ;)
ew
rbautch
07-10-2005, 12:00 PM
Very funny :) I know this script is fine, but is there any PATH or environment issue that might cause it to fail? Dam, I'm desperate for my Tivo to tell me my name.
edit: Changed computers and now it works. Still doesn't work on my laptop. Looks like I'll be writing scripts from my 5-year old daughter's computer.
eastwind
07-10-2005, 02:45 PM
Very funny :) I know this script is fine, but is there any PATH or environment issue that might cause it to fail? Dam, I'm desperate for my Tivo to tell me my name.
edit: Changed computers and now it works. Still doesn't work on my laptop. Looks like I'll be writing scripts from my 5-year old daughter's computer.
Are you writing a script on you PC and then transferring it to the TiVo? Maybe the problem is in the transfer? Did you look at the file after you transferred it?
ew
rbautch
07-10-2005, 02:55 PM
Yes, checked it after transferred. Ran dos2unix just to be sure. Using UltraEdit to create. After it's on my Tivo, runs fine when I telnet from one computer but not the other. It's got to be the Telnet session causing the problem. I have not idea what could be interfering.
edit: Turned out telnet client was adding extra line feed.
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.