Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Feb 28th, 2005, 12:50 PM   #1
jmsilver
Newbie
 
Join Date: Feb 2005
Posts: 2
Rep Power: 0 jmsilver is on a distinguished road
Question Problem read'ing from file and user input

I have a simple script which reads lines from a file (using a while-read loop) and asks the user whether to perform an action on each entry. The problem is that when I use read to prompt the user input, the user read gets data from the file read. Here is the code:

#!/bin/bash

[ -f "download.list" ] || exit 1

while read LINE
do
        URL=${LINE#*,}
        TITLE=${LINE%,*}
        echo "Download $TITLE [y/n]: "
        read RESPONSE

        if [ $RESPONSE = 'y' ]; then
               echo "curl -O $URL"
        fi

done < download.list

The $LINE, $URL & $TITLE are set correctly. What happens is that $RESPONSE is set to the next line in 'download.list' rather than prompting the user for input.

Can anyone tell me what I am doing wrong?

Thanks,
jmsilver is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:16 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC