GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  Programming  >  Perl
Go To First  |  Previous Question  |  Next Question 
 Perl  |  Question 53 of 61    Print  
How do you you check the return code of a command in Perl
Suppose you run a program/script in Perl:

system("./server ....");

How will you check the return code?



  
Total Answers and Comments: 2 Last Update: July 11, 2008     Asked by: mpathak 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
December 06, 2007 12:20:22   #1  
perl_guy Member Since: December 2007   Contribution: 1    

RE: How do you you check the return code of a command in Perl

system calls *traditionally* returns 0 when successful and 1 when it fails.

system ( cmd ) && die "Error - could run cmdn";


 
Is this answer useful? Yes | No
July 11, 2008 17:16:26   #2  
kglukhov Member Since: July 2008   Contribution: 2    

RE: How do you you check the return code of a command in Perl
# Retrieve the higher byte of the two-byte return code

my $ret = system("./server") >> 8;

 
Is this answer useful? Yes | No

 Related Questions

Here is a Perl Problem that was posed to me. I was given one day time to solve.  Unfortunately I did not know enough Perl to do it. And  sadly, I did not get selected.  However I wish to share this question with all. Please pose your answers or programs on this forum for the benefit of all friends. Submitted by  ilangocal.
Here is the link for the full questions in exforsys forum, see if you can answer ttp://www.exforsys.com/forum/showthread.php?t=499 

What's the significance of @ISA, @EXPORT @EXPORT_OK %EXPORT_TAGS list & hashes in a perl package? With example?

Latest Answer : The other trick is to use http://www.freetds.org/ for your sybase driver (M$SQL is just an old version of sybase that has been heavily modified).  Then standard DBI calls work.  Here is a program to login to an SQL server and print success if ...
Read Answers (3) | Asked by : Mehul

Latest Answer : There's also:-T for taint mode for security/input-checking-W for show all warnings mode (or -w to show less warnings) ...
Read Answers (2) | Asked by : suseel

Latest Answer : When to use Perl1. For large text processing2. When application does lot of data manipulation3. When you need fast development4. For database loading operations5. When shell scrits grow to become libraries ...
Read Answers (3) | Asked by : suseel

Latest Answer : It is having the features of scripting (Shell) as well as programming (like C). Using PERL you can easily do the system administration works where comparitively difficult with Shell script. ...
Read Answers (4) | Asked by : suseel

Latest Answer : HiThe faviurite module is undoubtly CGI.pmIt simplifies the coding as we no need to worry about the intricacies involving the form processing etc.Thanks,Abhishek jain ...
Read Answers (1) | Asked by : suseel

Latest Answer : hi! perldoc is best help to perl. ...
Read Answers (4) | Asked by : suseel

Latest Answer : When you are developing an application for a real time system in which processing speed is of utmost importnace ...
Read Answers (2) | Asked by : suseel

Latest Answer : You to install the appropriate driver for DB so that the connection can be make, just like ODBC drivers for each DB interface are needed... ...
Read Answers (3) | Asked by : suseel


 Sponsored Links

 
Related Articles

jQuery Table Row Finished Code

jQuery Table Row Finished Code The Finished Code Our second example page has demonstrated table row striping highlighting tooltips collapsing expanding and filtering Taken together the JavaScript code for this page is mosgoogle geshibot lang php" document ready function var highlighted
 

jQuery Interacting with Other Code

jQuery Interacting with Other Code We learned with our sorting and paging code that we can t treat the various features we write as islands The behaviors we build can interact in sometimes surprising ways; for this reason it is worth revisiting our earlier efforts to examine how they coexist with t
 

jQuery Completed sorting and paging code

Learning jQuery The Finished Code The completed sorting and paging code in its entirety follows mosgoogle geshibot lang php" fn alternateRowColors function tbody tr odd this removeClass even addClass odd ; tbody tr even this removeClass odd addClass even ; return this; ; document
 

code

geshibot lang javascript" head This is a JS snippet from Geshi Bot" Replaces the geshi default classes with mambo joomla classes function replaceGeshiWithMamboClasses if document document getElementsByTagName Category
 

Concepts of Object-Oriented Programming

Object Oriented JavaScript In this chapter you ll learn about OOP Object Oriented Programming and how it relates to JavaScript As an ASP NET developer you probably have some experience working with objects and you may even be familiar with concepts such as inheritance However unless you re already a
 

Working with XML in Perl

Working with XML in Perl Extensive Markup language or the XML is a sort of data storage; it is very structured and mapped out There are two most important aspects of XML that has to be covered one is writing in XML and reading it out in XML Parsers have already been created in XML and knowing how t
 

What is the use of truncate command?

Truncate command will delete all records and the most important thing to make note of truncate command is since truncate command cannot be rolled back one must make sure to take proper backup of table data before performing the truncate command. Truncate command is thus used to remove all rows from
 

printf() Function Return Value

What is the return value from printf() function? printf function always returns the number of characters printed. Let us understand this with an example: main() { int a=10; printf("%d",printf("%d %d %d", a,a,a)); } In this above program the inner printf i
 

What is the default return value of a function?

The default return value from a function is int. In other words, unless explicitly specified the default return value by compiler would be integer value from function.   When a programmer wants other than integer values to be returned from function then it is essential that the pro
 

How to define command line arguments

The main functions can have arguments passed which are called as command line arguments. There are two command line arguments: Argument count denoted by argc and Argument vector denoted by argv The argc is an integer variable which denotes the number of parameters passed and argv is pointer to a
 





About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape