last command status problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting last command status problem
# 1  
Old 11-19-2010
last command status problem

Hi

there is below code in my code , i did not understand what does it mean



RC=0
RC=$(( RC | $? ))




Please help me regarding this

---------- Post updated at 02:22 AM ---------- Previous update was at 01:46 AM ----------

Below is more example of the code



-bash-3.00$ rc=2; rc=$((rc | 2)); echo $rc
2
-bash-3.00$ rc=2; rc=$((rc | 8)); echo $rc
10
-bash-3.00$ rc=2; rc=$((rc | 7)); echo $rc
7
-bash-3.00$ rc=2; rc=$((rc | 6)); echo $rc
6
-bash-3.00$ rc=2; rc=$((rc | 4)); echo $rc
6




totally un understandable

please help me regarding this
# 2  
Old 11-19-2010
I think it is bit operation "OR". Like in the last example:
Code:
2=010, 4=100

  010
   OR
  100
-----
  110

110=6

# 3  
Old 11-19-2010
Either the author was 100% sure that RC could assume no value other than 0 or 1 and he felt he could get away with it, orr the author made a mistake and mixed up | and || .
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Exit Status of Command

Hi All, I am doing an export and import (datapump) of 4 schema. I know we can do an export of 4 schema in one command. But just want to know how to check the exit status if i do the export/import of 4 schema in different commands in background. Please suggest. Thanks, Mani (1 Reply)
Discussion started by: pvmanikandan
1 Replies

2. UNIX for Dummies Questions & Answers

Problem with script status table

I have a bunch of new, complex scripts that I'm running in Oracle via SQL*Plus under my UNIX account. In an attempt verify that various stages of the script have completed and to locate any errors I periodically toss in a statement such as INSERT INTO status_run9 VALUES... (0 Replies)
Discussion started by: Mike Welch
0 Replies

3. UNIX for Advanced & Expert Users

Equivalents of tee command to find exit status of command

Hi, Want to log the output of command & check the exit status to find whether it succeeded or failed. > ls abc ls: abc: No such file or directory > echo $? 1 > ls abc 2>&1 | tee log ls: abc: No such file or directory > echo $? 0 Tee commands changes my exit status to be always... (7 Replies)
Discussion started by: vibhor_agarwali
7 Replies

4. UNIX for Dummies Questions & Answers

How to know the status of a Command?

Hi i have done a copy operation (Storing one content of a file to another) For example : cp Fileone Filetwo Now is it possible to know the status of the execution of that command ?? Without manually checking the Filetwo contents ?? Thanks in advance . (5 Replies)
Discussion started by: Ravi Pavanv
5 Replies

5. Shell Programming and Scripting

problem in exit status of the command in a shell script-FTP

Hi All, I have developed below script for FTP a file from unix machine to another machine. ftpToABC () { USER='xyz' PASSWD='abc' echo "open xx.yy.zbx.aaa user $USER $PASSWD binary echo "put $1 abc.txt" >> /home/tmp/ftp.$$ echo "quit" >> /home/tmp/ftp.$$ ftp -ivn <... (3 Replies)
Discussion started by: RSC1985
3 Replies

6. Shell Programming and Scripting

Find exit status problem

Hi All Its strange or i am doing it wrong.When find run successful it return exit status 0.And same if it didn't run successfully it return zero. find /var/www/html -maxdepth 1 -type f -name *.dsadas echo $? 0 find /var/www/html -maxdepth 1 -type f -name *.php... (1 Reply)
Discussion started by: aliahsan81
1 Replies

7. Shell Programming and Scripting

Move Command and exit status problem

Hi All, I am using the following code to move files from one folder to another on the remote server: ssh username@server <<EOF cd source_dir find . -type f -name "*.txt" |xargs -n1000 -i{} mv {} dest_dir if then send mail indicating error otherwise echo "success" fi EOF ... (10 Replies)
Discussion started by: visingha
10 Replies

8. UNIX for Dummies Questions & Answers

Move Command and exit status problem

Hi All, I am using the following code to move files from one folder to another on the remote server: ssh username@server <<EOF cd source_dir find . -type f -name "*.txt" |xargs -n1000 -i{} mv {} dest_dir if then send mail indicating error otherwise echo "success" fi EOF ... (1 Reply)
Discussion started by: visingha
1 Replies

9. Shell Programming and Scripting

Status of the second to last command

Below is a chuck of a shell script I have written. The problem I am having is with the test section. I want to test the status of the f60gen command but since I'm running the output of the f60gen command into tee, the test command is actually testing "tee" and not "f60gen". Is there a way to... (5 Replies)
Discussion started by: goswell
5 Replies

10. Shell Programming and Scripting

Problem with exit status

Hi, Consider the output of the following commands: case1) ------- # ifconfig -a | grep "UP" | grep uplink0:1 # echo $? Output is: 0 case2 ------ # ifconfig -a | grep "UP" | grep uplink0:1; echo $? Output is: 1 In case2 we got the exit code as 1, which is the actual exit code.... (1 Reply)
Discussion started by: diganta
1 Replies
Login or Register to Ask a Question