Sponsored Content
Full Discussion: confusion in use of exit 0
Top Forums Shell Programming and Scripting confusion in use of exit 0 Post 302713591 by scriptor on Friday 12th of October 2012 11:12:30 AM
Old 10-12-2012
waiting for reply
plz respond

---------- Post updated at 12:27 PM ---------- Previous update was at 12:22 PM ----------

so this means that getting 'a' is obvious and the output is correct .
and
sry plz ignore my previous post.

---------- Post updated at 04:53 PM ---------- Previous update was at 12:27 PM ----------

so this means that getting 'a' is obvious and the output is correct .

---------- Post updated 10-12-12 at 04:00 PM ---------- Previous update was 10-11-12 at 04:53 PM ----------

one more confusion.

my below script is not giving expected output.

Code:
$ cat -n pmeter2
     1  #!/bin/sh
     2  USAGE="Usage: `basename $0` [-c|-t] [files|directories]"
     3  if [ $# -lt 2 ] ; then
     4  echo "$USAGE" ;
     5  exit 1 ;
     6  fi
     7  case "$1" in
     8  -t) shift ; TARGS="-tvf" ;
     9  for i in "$@" ; do
    10  if [ -f "$i" ] ; then
    11  FILES=`tar $TARGS "$i" 2>/dev/null`
    12  if [ $? -eq 0 ] ; then
    13  echo ; echo "$i" ; echo "$FILES"
    14  else
    15  echo "ERROR: $i not a tar file."
    16  fi
    17  else
    18  echo "ERROR: $i not a file."
    19  fi
    20  done
    21  ;;
    22  -c) shift ; TARGS="-cvf" ;
    23  tar $TARGS archive.tar "$@"
    24  ;;
    25  *) echo "$USAGE"
    26  exit 0
    27  ;;
    28  esac
    29  exit $?

when i ran the script like (where f1 is a file name).
Code:
$ ./pmeter2 -t f1

i am getting below o/p
Code:
f1

but the expected output should be as "f1 is not a tar file".

can you please pin point my error.

---------- Post updated at 04:15 PM ---------- Previous update was at 04:00 PM ----------

plz respond to my query

Moderator's Comments:
Mod Comment edit by bakunin: please keep in mind that we are no helpdesk and bumping up threads is forbidden by our rules. If you want reliable responsible consultancy within a certain amount of time please consider hiring an expert instead of pestering us for not answering within a certain timeframe.

All this will get you is stony silence and some infractions. Thank you for your consideration.


---------- Post updated at 08:42 PM ---------- Previous update was at 04:15 PM ----------

hi bakunin
ok . i accept my mistake. and sorry for that.
this is purely a mistake and not intentially.

i will wait for my answer.

thx
vk

Last edited by bakunin; 10-12-2012 at 08:49 AM..
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Please help me clear up some confusion

Hello All, I like this forum btw, and have only been lurking for about a day. Recently I purchased some new hardware (AMD Athlon 64 3200+ and a Asus K8V Deluxe Motherboard), and I want to find an OS that can take advantage of the 64 bit processor. Basically, what are the differences... (2 Replies)
Discussion started by: RoY_mUnSoN
2 Replies

2. UNIX for Dummies Questions & Answers

Where can I find a list of exit codes? (Exit code 64)

I'm receiving an exit code 64 in our batch scheduler (BMC product control-m) executing a PERL script on UX-HP. Can you tell me where I can find a list of exit codes and their meaning. I'm assuming the exit code is from the Unix operating system not PERL. (3 Replies)
Discussion started by: jkuchar747
3 Replies

3. UNIX for Dummies Questions & Answers

ftp confusion

I'm an intern at a company that recently bought out another business. In doing so, they inherited a unix system that contains files which they need to retrieve. No one in the company, including myself, really understands or knows unix so please respond with the true assumption that I'm a unix... (1 Reply)
Discussion started by: intern
1 Replies

4. Programming

exit(0) versus exit(1)

What is the difference between using exit(0) and exit(1) to exit a program? Which should I use? (9 Replies)
Discussion started by: enuenu
9 Replies

5. UNIX for Dummies Questions & Answers

what is meaning of exit(0) and exit(1)

can u tell me what is the meaning of exit(0),exit(1),exit(2) what is diff amonng these. Amit (1 Reply)
Discussion started by: amitpansuria
1 Replies

6. UNIX for Dummies Questions & Answers

'tr' confusion

Good day, everyone! Could anybody explain me the following situation. If I'm running similar script: Var="anna.kurnikova" Var2="Anna Kurn" echo $Var | tr -t "$Var" "$Var2" Why the output is : anna KurniKova instead of Anna Kurnikova? :confused: Thank you in advance for any... (2 Replies)
Discussion started by: Nafanja
2 Replies

7. UNIX for Dummies Questions & Answers

crontab confusion

I come across an entry in cron which is in such: 0 * * * * What is the first 0 indicating? 0 minute? meaning a script cron as such will run every minute? :confused: (2 Replies)
Discussion started by: user50210
2 Replies

8. Shell Programming and Scripting

Confusion with PS

Hello All, I have a problem in counting number of process getting run with my current script name.. Here it is ps -ef | grep $0 | grep -v grep This display just one line with the PID, PPID and other details when i print it in the script. But when I want to count the numbers in my... (11 Replies)
Discussion started by: sathyaonnuix
11 Replies

9. Shell Programming and Scripting

Need the difference between exit 1 & exit 7

Hi In one of the script I am seeing some thing like exit 7,exit 1,exit 2,exit 3,exit 9,exit6.What is the difference between all of this exit.Can anyone help here please (3 Replies)
Discussion started by: ginrkf
3 Replies
All times are GMT -4. The time now is 02:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy