Solved

how to use exit?

Posted on 2000-04-24
7
216 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
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

707 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now