Solved

how to use exit?

Posted on 2000-04-24
7
223 Views
Last Modified: 2010-03-05
1.What's the difference between

exit (0) and exit(1)?

please give me a example.
0
Comment
Question by:li_fang
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 2746396
print system('perl -e "exit(0)"')/256,"\n";
print system('perl -e "exit(1)"')/256,"\n";
#perldoc -f exit
0
 
LVL 16

Expert Comment

by:maneshr
ID: 2747355
Here is some info about exit.

exit status

Exits the current Perl process immediately with that value given by status. This could be the entire Perl script you are running,
or only a child process created by fork

If status is omitted, the function exits with 0. You shouldn't use exit to abort a subroutine if there's any chance that someone
might want to trap whatever error happened. Use die instead, which can be trapped by an eval.

Hope that helps
0
 
LVL 8

Accepted Solution

by:
shlomoy earned 10 total points
ID: 2748351
Use exit(0) if your program finishes with succes.
Use exit(1) (or any other value other than 0) - to alert that your program finished with a problem.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:meerak
ID: 2749148
To check the exit status from the shell use:
echo $? on ksh and sh and
echo $status on csh
0
 

Author Comment

by:li_fang
ID: 2749787
It's what i want!
0
 
LVL 84

Expert Comment

by:ozo
ID: 2749944
use POSIX;
exit( $? ? EXIT_FAILURE:EXIT_SUCCESS );
0
 

Author Comment

by:li_fang
ID: 2753661
hi,ozo
I can't understand your answer,you are expert,I'm beginner:(,thanks!
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question