LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 07-09-2005, 12:06 AM   #1
jiawj
Member
 
Registered: Jul 2004
Location: Beijing, China
Distribution: Slackware,Redhat
Posts: 121

Rep: Reputation: 15
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.
 
Old 07-09-2005, 03:11 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,005
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
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
 
Old 07-09-2005, 07:15 PM   #3
eddiebaby1023
Member
 
Registered: May 2005
Posts: 378

Rep: Reputation: 33
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.

Last edited by eddiebaby1023; 07-09-2005 at 07:17 PM.
 
Old 07-14-2005, 12:45 PM   #4
jiawj
Member
 
Registered: Jul 2004
Location: Beijing, China
Distribution: Slackware,Redhat
Posts: 121

Original Poster
Rep: Reputation: 15
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A question about BASH operand Linux - Newbie 2 11-27-2005 10:49 PM
BASH question robscott Linux - Software 3 11-23-2005 10:39 AM
Bash question lnxduck Programming 3 09-30-2005 09:50 AM
bash question? shanenin Linux - Software 1 11-26-2004 01:22 PM
little bash question gplacek Linux - General 2 09-01-2004 01:10 PM


All times are GMT -5. The time now is 08:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration