LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-24-2004, 08:30 AM   #1
Thomas23
LQ Newbie
 
Registered: May 2004
Posts: 4

Rep: Reputation: 0
while-loop


This works:

cat $hulp | while IFS=: read a1 a2 a3
do
some things
done


What is wrong with this one?

cat $hulp | while [ IFS=: read a1 a2 a3 ] && [ !$HTTP_COOKIE ]
do
some things
done
 
Old 05-24-2004, 11:46 AM   #2
wapcaplet
LQ Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Rep: Reputation: 48
Maybe the assignment statement? I think that this:

Code:
IFS=: read a1 a2 a3
Should be this:

Code:
IFS := read a1 a2 a3
At least, with bash I'm fairly sure that's the correct assignment syntax...
 
Old 05-24-2004, 12:23 PM   #3
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 110Reputation: 110
Quote:
What is wrong with this one?

cat $hulp | while [ IFS=: read a1 a2 a3 ] && [ !$HTTP_COOKIE ]
do
some things
done
Don't use the square brackets around "IFS=: read a1 a2 a3". They are use for testing things. In this case you are not testing enything...

In "[ !$HTTP_COOKIE ]" the square brackets are needed probably, but it's not very clear what you want to do in this case. The syntax is wrong. If $HTTP_COOKIE contains a file name, and you want to test if that file does not exist, use:
Code:
cat $hulp | while [ IFS=: read a1 a2 a3 ] && [ ! -f $HTTP_COOKIE ]
do
some things
done
if ypu want to do something else with this part, tell us what it is that you would like it to do.

Last edited by Hko; 05-24-2004 at 12:25 PM.
 
Old 05-24-2004, 03:04 PM   #4
Thomas23
LQ Newbie
 
Registered: May 2004
Posts: 4

Original Poster
Rep: Reputation: 0
what i want...

i want to test if a cookie exists...

so testing if the cookie is a file isn't what i'm lokking for...

cat $hulp | while [ IFS=: read a1 a2 a3 ] && [ ! -f $HTTP_COOKIE ]
do
some things
done

Greetings from Holland,
Thomas
 
Old 05-24-2004, 04:35 PM   #5
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 110Reputation: 110
Re: what i want...

Quote:
i want to test if a cookie exists...
What kind of string does $HTTP_COOKIE contain? A cookie_ID, like "1618210828" ?

And what does a line in the file $hulp look like? Does it have a field that has the cookie_ID you want to check for?

Please provide this info, it's not very clear what you would like to test.

Quote:
cat $hulp | while [ IFS=: read a1 a2 a3 ] && [ ! -f $HTTP_COOKIE ]
This part: "[ IFS=: read a1 a2 a3 ]" is still not correct. Remove the '[' and ']'.

Quote:
Greetings from Holland,
Dacht ik al :-) vanwege "hulp".

Last edited by Hko; 05-24-2004 at 04:36 PM.
 
  


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
while loop or for loop? mijohnst Programming 18 11-21-2005 05:48 PM
No loop# SeaSharp Linux - Newbie 3 09-06-2005 09:14 PM
WHILE LOOP in 'C' ']['HeBroken Programming 4 10-29-2004 02:42 AM
for loop klfreese Programming 16 08-11-2003 12:09 PM
help with the following C loop ..... purpleburple Programming 12 08-06-2002 11:32 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration