Problem wit the $? variable

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem wit the $? variable
# 1  
Old 08-10-2009
Problem wit the $? variable

Hi Friends,

I have a problem when i run this piece of script, and do echo $? it always gives me value 0, even if the string "CCRCWebServerINSTALLDIR" is not present in that file. Why is that so, can you give me suggestion to the changes i need to make?

$find /home/administrator/testfix/install/cc.offering/ -exec  grep CCRCWebServerINSTALLDIR {} \;

# 2  
Old 08-10-2009

Find doesn't return an error in that case.

find /home/administrator/testfix/install/cc.offering/ | xargs grep CCRCWebServerINSTALLDIR
echo $?

# 3  
Old 08-10-2009
Thanks Scottn
# 4  
Old 08-10-2009
'$?' is among some of the special parameters that are designated by the shel for yielding information about the environment in general and the process being executed.

'$?' is the exit status of the last executed command , which is 0 for success and 1 for failure
list of other parameters are...
$$- PID of current shell
$!- PID of last background process
$- -current shell settings
$#- total no. of positional parameters
$0 - name of the command being executed
$* - list of all shell arguments. Cant yield each argument separately
$# - similar to $*, but yields each argument separately when enclosed with double quotes.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

problem in assigning value to variable have value fo other variable

my script is some thing like this i11="{1,2,3,4,5,6,7,8,9,10,11,}" echo "enter value" read value ..............suppose i11 x="$value" echo "$($value)" .............the echo should be {1,2,3,4,5,6,7,8,9,10,11,} but its showing "i11" only. plz help me out to get desired... (10 Replies)
Discussion started by: sagar_1986
10 Replies

2. Shell Programming and Scripting

Variable print problem

Hi, I'm facing some problem with printing the values in the variables I have passed all the database values into the variable, but when i echo the variable i get the values printed in one line var=`echo <query> | database` echo $var or awk 'BEGIN {printf("%s\n","'"${var}"'")}' this... (4 Replies)
Discussion started by: prash_b
4 Replies

3. Shell Programming and Scripting

Problem with a variable withing a variable

hello there, basically im screwed with a variable that should take the last modification date of a file. my code is fileCreationTime=$(( `ls -l $fileName | tr -s " " | cut -d " " -f6` )) my problem arise coz when the code is executed and stored in a file the return value is 1993 and not... (4 Replies)
Discussion started by: thurft
4 Replies

4. Linux

Partition of linux filesystem wit meaning

Cud some one pls help me wit some partitions of linux filesystem wit their meaning....urgent cos is an assignment (5 Replies)
Discussion started by: GODBLESSME
5 Replies

5. Shell Programming and Scripting

Problem with variable value

Can anyone help me?...I don't know why the second 'echo $contador' always shows 0 (zero): 1 #!/bin/bash 2 contador=0 3 while read linea 4 do 5 echo 6 echo "$linea" | while IFS="" read -n 1 caracter 7 do 8 contador=$((${contador}+1)) 9 echo $contador... (5 Replies)
Discussion started by: albertogarcia
5 Replies

6. Shell Programming and Scripting

Problem with * when pass into variable.

Hello expert. I have a little problem here. I write a script and stuck some bug to fix. I found the problem was about * and a sample of script is below. line 1 is print * out but line 3 print all name of files in the script's path. (but I want *) I want to contain * in variable... (3 Replies)
Discussion started by: MaYuMi
3 Replies

7. Shell Programming and Scripting

Problem with variable use

Hi, I need a little help with variable use: I have the a file with follow format: Type: Test Profile: 010 84240 27 15 84900 11 09 84993 55 44 84762 12 12 I need to look the value in the line containing "Profile" and put in front of the lines containing numbers... (6 Replies)
Discussion started by: cgkmal
6 Replies

8. UNIX for Dummies Questions & Answers

Variable assignment problem

Hi, I am having a problem with assigning a value to a variable. The empname is looked for in the employees file and I am trying to assign it to the jobnum variable in the following statement jobnum= cat/etc/employees | grep $empname | cut -d : -f 5 It is getting the right answer but it is... (3 Replies)
Discussion started by: rodney08
3 Replies

9. UNIX for Dummies Questions & Answers

Variable Size Problem

Hello Everyone, I am currently working with a DB2 (ver 8.1) table (Newly Created) and I am running a basic DB2 Select query into a variable. The field and it's size are VARCHAR(20). Since I need to pass the variable through some java I have noticed that when the results come back from the query... (0 Replies)
Discussion started by: Bob_Loblaw
0 Replies

10. Shell Programming and Scripting

Help me in this variable problem

suppose i declare a=b b=30 echo $(echo $a) i need to get the value as 30 i dont know if im right but it prints only 'b' as output. How can i get the value referred by 'b' through the value of 'a' (4 Replies)
Discussion started by: SankarV
4 Replies
Login or Register to Ask a Question