Why does my test fail ??


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Why does my test fail ??
# 1  
Old 01-27-2012
Why does my test fail ??

Hello,

I am stuck... i dunno why does my test fail... any idea ?
Code:
#!/bin/bash
dos2unix info.txt
Distor=Distributeur
LINE=$(cat info.txt | sed -n 1p)
echo $LINE
echo $Distor
echo ""
echo "123-$LINE-123"
echo "123-$Distor-123"
if [ "$LINE" = "$Distor" ]; then
LINE2=$(cat info.txt | sed -n 2p)
echo $Distor
echo $LINE2
else
echo failed
fi

output:
Code:
Distributeur
Distributeur

123-Distributeur-123
123-Distributeur-123
failed

# 2  
Old 01-27-2012
you can read the first line without putting cat and sed in backticks by doing read LINE < file to avoid using anything but pure shell builtins.

Are you sure that one of those "Distributeur" doesn't have an accent on the e or something? It looks like a French word.
# 3  
Old 01-27-2012
Tthere are no accents on Distributeur... it does not seems to have any trailing space or line return either...

thank you

Last edited by patx; 01-27-2012 at 04:18 PM..
# 4  
Old 01-27-2012
Quote:
Originally Posted by patx
Yeah good point, i used read LINE < info.txt but i had problems with trailing line return to be included into the variable
Had problems with it being included, or without it being included?

If it was being included, you had a strange value of IFS being set. If it wasn't set and you didn't need one, I'm not sure why you'd need one.

Could you attach the text file itself, or at least the first 2 lines of it?
# 5  
Old 01-27-2012
info.txt before stripping accents:

Before i did a dos2unix the read LINE < info.txt was including a line return into the variable

Code:
Distributeur
Alliance Vivafilm
Origine
États-Unis
Genre
Suspense
Durée
1h46
Classification

Synopsis
D’aussi loin qu’il se souvienne, Nathan Harper (Taylor Lautner) a toujours eu le sentiment de vivre la vie de quelqu’un d’autre. Lorsqu’il tombe sur une photo de lui petit sur un site Web listant des enfants disparus, ses pires cauchemars deviennent réalité : ses parents ne sont pas les siens et toute sa vie est un mensonge fabriqué pour cacher quelque chose d'encore plus mystérieux et dangereux qu’il ne peut l’imaginer.
Site officiel
http://www.abductionthefilm.com/
 Critiques des internautes&nbsp;&nbsp;|&nbsp;
v.f. de Abduction
Réalisation: John Singleton
Distribution: Alfred Molina, Jason Isaacs, Lily Collins, Maria Bello, Sigourney Weaver, Taylor Lautner.

# 6  
Old 01-27-2012
By copy-pasting it into a web browser you've put it through many layers of translation. I doubt the problem would exist if I used the text from your post.

By attach, I mean attach. As a file attachment.
# 7  
Old 01-27-2012
ho attach you said... here it is
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. Forum Support Area for Unregistered Users & Account Problems

Fail to register

After inputted all required fields in registration page, the below message is shown and cannot go on. A required field called Custom Date & Time Formats is missing or has an invalid value. (2 Replies)
Discussion started by: Unregistered
2 Replies

2. Shell Programming and Scripting

Untar fail

Hi Team, I have a file named as follows: aaa.tar.gz Now I need to verify if the untar fails, then the script has to send a mail. In order to check this condition, I need a tar.gz file which is unable to untar it. Can anyone help me to create a file which I will be able to unzip successfully... (2 Replies)
Discussion started by: kmanivan82
2 Replies

3. Shell Programming and Scripting

Prefixing test case methods with letter 'test'

Hi, I have a Python unit test cases source code file which contains more than a hundred test case methods. In that, some of the test case methods already have prefix 'test' where as some of them do not have. Now, I need to add the string 'test' (case-sensitive) as a prefix to those of the... (5 Replies)
Discussion started by: royalibrahim
5 Replies

4. Shell Programming and Scripting

How to check weather a string is like test* or test* ot *test* in if condition

How to check weather a string is like test* or test* ot *test* in if condition (5 Replies)
Discussion started by: johnjerome
5 Replies

5. Shell Programming and Scripting

Test on string containing spacewhile test 1 -eq 1 do read a $a if test $a = quitC then break fi d

This is the code: while test 1 -eq 1 do read a $a if test $a = stop then break fi done I read a command on every loop an execute it. I check if the string equals the word stop to end the loop,but it say that I gave too many arguments to test. For example echo hello. Now the... (1 Reply)
Discussion started by: Max89
1 Replies

6. Solaris

cdrom test fail

Hi I have a problem in installing solaris 9 in a ULTRA Enterprise 2 machine. The cdrom does not keep the cd in. When I put the installtion cd 1 and close the tray, I can see the led blinks three times and then the tray comes out. I borrowed a set of installtion cd s from one of my friends (they... (3 Replies)
Discussion started by: enke1234
3 Replies
Login or Register to Ask a Question