Solved

how to use exit?

Posted on 2000-04-24
7
218 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Perl Sort Question 4 135
Trying to use two loops in a perl script but not getting results need. 10 88
Exchange 2010 Transport Rule Regex 28 108
Perl string replace for refred url 9 62
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…
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 …
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

773 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