You are not logged in.

#1 2010-06-12 01:47:10

zuargo
Member
From: Concepción, Chile
Registered: 2009-08-20
Posts: 116

using back and forward keys with the read command (bash)

Hello all

I have took a script and made a little modifications on it, specifically, I have added the command read on it:

#!/bin/bash
USERNAME=""
PASSWORD=""
URL=http://www.gnewbook.org/api/update.php 
echo -n "Join the message:"
[b]read MESSAGE[/b]
RST=$(curl -s -u $USERNAME:$PASSWORD -d status="$MESSAGE" $URL > /tmp/gNewBook_up2date.log)
IDS=$(cat /tmp/gNewBook_up2date.log | grep "</id>" | head -n1 | cut -d '>' -f2 | cut -d '<' -f1)
echo "Post on gNewBook with ID:"$IDS
exit 0

This script allows to send updates of status to the system of microbbloging on gnewbook.org, through curl.

I have added the command read and established their output like a variable named MESSAGE:

read MESSAGE

Well, if you run the script at the moment that it says:

Join the message:

You can write it but you can not use the key back or forward, becouse, the terminal prints something like ^[[C^[[C^[[C^[[C^[[D^[[D^[[D^[[D^[[D^[[D^[[D

So, I want to know if exist any way to fix it this behaviour

Thanks in advance and sorry my poor english I talk spanish tongue

Offline

#2 2010-06-12 09:19:27

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

Re: using back and forward keys with the read command (bash)

man bash

Offline

#3 2010-06-12 15:06:11

cmtptr
Member
Registered: 2008-09-01
Posts: 135

Re: using back and forward keys with the read command (bash)

Procyon wrote:

man bash

I've hardly ever found the bash manual to be very helpful since it's over 5000 lines long and when I have questions about a shell they rarely have clear, searchable keywords (such as this one).

Anyway, I found this using Google (the same question has been asked before):

              -e     If the standard input is coming from a terminal, readline
                     (see READLINE above) is used to obtain the  line.   Read‐
                     line  uses  the  current (or default, if line editing was
                     not previously active) editing settings.

It produces the behavior you're looking for, zuargo.  How you would have found and interpretted this to be what you're looking for is beyond me.

Offline

#4 2010-06-12 17:37:27

zuargo
Member
From: Concepción, Chile
Registered: 2009-08-20
Posts: 116

Re: using back and forward keys with the read command (bash)

cmtptr wrote:
Procyon wrote:

man bash

I've hardly ever found the bash manual to be very helpful since it's over 5000 lines long and when I have questions about a shell they rarely have clear, searchable keywords (such as this one).

Anyway, I found this using Google (the same question has been asked before):

              -e     If the standard input is coming from a terminal, readline
                     (see READLINE above) is used to obtain the  line.   Read‐
                     line  uses  the  current (or default, if line editing was
                     not previously active) editing settings.

It produces the behavior you're looking for, zuargo.  How you would have found and interpretted this to be what you're looking for is beyond me.

Thanks a lot you are very gentile smile

Offline

Board footer

Powered by FluxBB