LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   a bash question about while (https://www.linuxquestions.org/questions/linux-newbie-8/a-bash-question-about-while-341469/)

jiawj 07-08-2005 11:06 PM

a bash question about while
 
hello

when I run this at command-line mode:

Quote:

[root@localhost ~]# addr=221.216.157.121:3128
[root@localhost ~]# echo "http://"$addr"/"
http://221.216.157.121:3128/
that is ok!

but, if I run it within while on a bash-script:

Quote:

while read line
do
http_proxy="http://"${line}"/"
echo ${http_proxy}
done < httpname
httpname file content is 221.216.157.121:3128


but echo ${http_proxy} display \/tp://221.216.157.121:3128

why, and thx for any idea.

Tinkster 07-09-2005 02:11 AM

All I can say is: "Works for me"

Did you copy and paste the IP into the file
somehow? Maybe have a look with a hex
editor or something?


Cheers,
Tink

eddiebaby1023 07-09-2005 06:15 PM

Do you get the same behaviour if you change
Code:

echo ${http_proxy}
to
Code:

echo "${http_proxy}"
Also, you're not actually quoting the $(line) part of the assignment, you don't need the inner pair of quotes.

jiawj 07-14-2005 11:45 AM

thx eddiebaby1023,but .....

I try the method as your suggestion, but still failed

and , I find the line
Quote:

http_proxy="http://"${line}
must change as
Quote:

http_proxy='http://'${line}
then , the bash script work fine.


All times are GMT -5. The time now is 04:48 AM.