Results 1 to 8 of 8

Thread: Unable to accept input during a script (read command)

  1. #1

    Unable to accept input during a script (read command)

    I am having some trouble with my Tivo that I can't solve on my own. Ill try to keep this short -

    I am having trouble with the read command. For some reason it is not accepting any input.

    For example if I run it directly from the bash prompt as follows
    read test
    and type
    123
    Then run the set command I can see that an environment variable named test has been created but it is blank.

    Once the read command has exited the string I typed (123 in this example) is then output to the bash prompt.

    The same thing happens in a script. For example
    echo "enter password"
    read password
    echo $password


    Will echo nothing and then whatever I typed during the script will then be entered at the bash prompt usually with a "command not found" error
    In other words I cant create a script that takes input from the user!

    Any help?

  2. #2
    Join Date
    Feb 2007
    Location
    NSW
    Posts
    108
    That's strange. Have you tried putting read in single quotes (which will ensure that the real command is used, not an alias)
    Also using test as a variable name is probably not a good idea as it's a bash builtin command
    try
    Code:
    'read' ans
    echo $ans

  3. #3
    Thanks for the ideas. I created a file named script1.sh containing
    echo ANS
    'read' ANS
    echo $ANS
    echo ANS

    and ran it using sh script1.sh but it had the same problem.

  4. #4
    Join Date
    Feb 2007
    Location
    NSW
    Posts
    108
    Can you try the following commands, and paste the results here (response from Tivo in red your input in black):

    Code:
    [TiVo [p1] ~]# exec /bin/bash
    bash-2.02# 'read' ans
    123
    bash-2.02# echo $ans
    123
    bash-2.02#
    Are you connected to the tivo using telnet or serial port?

  5. #5
    Connected to the Tivo over the internet

    /var/tmp# exec /bin/bash
    /var/tmp#
    /var/tmp# 'read' ans
    123

    /var/tmp# 123
    bash: 123: command not found
    /var/tmp#
    /var/tmp#
    echo $ans

    /var/tmp#

    I was VERY careful to accurately represent my input from the Tivo's ouput using color. Notice the line above "command not found"
    Here is the truncated output of "set"
    ...
    _=echo
    ans=
    prom=r
    ...

    Notice that "ans" is getting set by read but the input is getting dumped back to the next bash prompt.

  6. #6
    Join Date
    Feb 2007
    Location
    NSW
    Posts
    108
    Ah - I think I know what the problem is. Your telnet client is sending 2 newlines when you hit enter (or at least that's how the TiVo is interpreting it).
    you can see this because you get an extra prompt after each command. Are you using putty as your telnet client by any chance? You need to change a setting in your telnet client. For putty, under Connection/telnet untick the box which says 'Return key sends Telnet new Line instead of ^M'

    Matt

  7. #7
    LOL!! MattCallow wins the internet for today. I posted this question all over the place including many Linux forums and IRC channels where people either didnt answer or said stuff like "your bash is really broken" ...

    I tried using hyperterminal and it worked. Originally I was using telnet.exe so I will try to out how to adjust its settings.

    Thanks I owe you one.

    edit: For windows Telnet.exe
    unset crlf
    Line feed mode - Causes return key to send CR
    and
    set crlf
    New line mode - Causes return key to send CR & LF
    Last edited by ciper; 06-11-2007 at 12:01 PM.

  8. #8
    Join Date
    Feb 2007
    Location
    NSW
    Posts
    108
    Glad to be of help. It's a difficult one to diagnose unless you see the exact input and output. I only know about it because I had experienced the problem with putty.

    Matt

Similar Threads

  1. swupdate cron script and log
    By boritz in forum Australian TiVoHD
    Replies: 2
    Last Post: 14-03-2018, 04:56 PM
  2. script for show deletion
    By reticent in forum Question and Answer Forum
    Replies: 5
    Last Post: 28-03-2007, 12:57 AM
  3. What is the command to set ReceiverNumDigits to 1?
    By kwijibot in forum Question and Answer Forum
    Replies: 3
    Last Post: 27-05-2006, 06:47 PM
  4. Daily Call Script
    By BenD in forum Question and Answer Forum
    Replies: 5
    Last Post: 18-02-2006, 02:01 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •