Perl Error 256 System
Contents |
Tutorials Poetry RecentThreads NewestNodes Donate What'sNew on May 19, 2001 at 01:33UTC ( #81640=perlquestion: print w/replies, xml ) Need Help?? Ras has asked for the wisdom of the Perl Monks concerning the following question: Does any body knows what happens when you exit code 256 in unix do a system call and it returns 256? Do you know what 256
Perl System Return Code 256
means? Thanks in advance Edited 2001-05-18 by Ovid Comment on System Return Code (was: 256) Replies are listed 'Best exit code 256 informatica First'. Re: System Return Code (was: 256) by kschwab (Priest) on May 19, 2001 at 17:26UTC The perl docs actually do have a good explanation of what the return value from system() is,
C++ System Return Code 256
but it's in "perldoc perlvar" instead of "perldoc -f system". system() returns the value of $? after the wait() is done. Here it is: $? The status returned by the last pipe close, backtick (``) command, or system() operator. Note that this is the status word returned by the wait() system call (or else is made up to look like it). Thus, the exit value of perl return code 2 the subprocess is actually ($? >> 8), and $? & 127 gives which signal, if any, the process died from, and $? & 128 reports whether there was a core dump. (Mnemonic: similar to sh and ksh.) Just to clarify, $? >> 8 is bitshifting by 8, which is essentially dividing by 256. So, if you are getting a return val of 256 from system(), your spawned program did an exit(1).[reply][d/l] Re: 256 by no_slogan (Deacon) on May 19, 2001 at 01:40UTC You mean... $result = system("foo") sets $result to 256? It means "foo" returned 1. Read "man foo" to see what that means - probably something went wrong. Or not. I need more information to be helpful.[reply][d/l] Re: 256 by Beatnik (Parson) on May 19, 2001 at 01:38UTC AFAIK it's application dependent. system() returns the application status/exit code, so whatever the application passes along as exit code is catcheable in your perl code.256 could be anything really :) Greetz Beatnik ... Quidquid perl dictum sit, altum viditur.[reply][d/l] Back to Seekers of Perl Wisdom Log In? Username: Password: remember me What's my password? Create A New User Node Status? node historyNode Type: perlquestion [id://81640]Approve
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of
Perl System Exit Code
this site About Us Learn more about Stack Overflow the company Business Learn
Wexitstatus
more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question perl system call x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up http://www.perlmonks.org/?node_id=81640 Why is the return value of Perl's system not what I expect? up vote 2 down vote favorite Let me begin by explaining what I'm trying to accomplish. Essentially there are two Perl scripts. One is what I call the Main script with an UI. The user who runs this script will see a list of other scripts he can call from the http://stackoverflow.com/questions/3882677/why-is-the-return-value-of-perls-system-not-what-i-expect menu. This list is loaded through a custom config file. The purpose of the main script is to be able to add other scripts in the future as needed without changing the source and be run either as cron job (Non-Interactive mode) and as the user needs (Interactive Mode). As company policy, I am not entitle to post the entire script, so I will post the Interactive-Mode user selection section: for($i = 0;$i < @{$conf}+1;$i++) { if($i % 2 == 1 || $i == 0) { next; } print $n++ . ". @{$conf}[$i-1]\n"; } print "(health_check) "; # # User selection # my $in = <>; chomp($in); if($in =~ /[A-Za-z]/) { write_log("[*] Invalid Selection: $in"); print "\n<<<<<<<<<<<<>>>>>>>>>>>>>\n"; print ">>> Invalid Selection <<<\n"; print "<<<<<<<<<<<<>>>>>>>>>>>>>\n"; } elsif($in == 0) { write_log("Exiting interactive mode"); last; } elsif(scalar($scripts[$in])) { write_log("[*] running: $scripts[$in]"); $rez = system('./' . "$scripts[$in]"); if($rez == 0b00) { printf("%s: [OK]\n",$scripts[$in]); } elsif($rez == 0b01) { printf("%s: [WARNING]\n",$scripts[$in]); } elsif($rez == 0b11) { printf("%s: [NOT OK]\n",$scripts[$in]); } else { print "UNKOWN ERROR CODE: $rez\n"; } } else { write_log("[*] Invalid Selection: $in"); print "\n<<<<<<<<<<<<>>>>>>>>>>>>>\n"; print ">>> Invalid Selection <
New? Today's Posts FAQ Rules Guidelines Search Advanced Search Forum :: Server side development Perl/ CGI system() function returning a value 256 ? If this is your first visit, be sure to check out the http://www.codingforums.com/perl-cgi/95555-system-function-returning-value-256-a.html FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Enjoy an ad free experience by logging in. Not a member yet? Register. Page 1 of 2 12 Last Jump to page: Results 1 to 15 of 16 Thread: system() function returning a value code 2 256 ? Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Rate This Thread Current Rating Excellent Good Average Bad Terrible 09-08-2006,06:39 AM #1 ganesh_mak View Profile View Forum Posts Regular Coder Join Date Sep 2005 Posts 113 Thanks 0 Thanked 0 Times in 0 Posts system() function returning a value 256 ? Hi, i have test.cgi file in cgi-bin directory . test.cgi Code: #! /usr/bin/perl use CGI; print return code 2 start_html(); system('sudo ls'); print end_html; even i have added the apache user with certain permission to execute the ls command in /etc/sudoers file. when i run it through command line its working perfectly fine.but when i run it through web browser i am getting no o/p as system() is returnning a value of 256. i am using apache on fedora core -3 can anybody help me out in solving this ? thanks Reply With Quote 09-08-2006,06:56 AM #2 FishMonger View Profile View Forum Posts Super Moderator Join Date May 2005 Location Southern tip of Silicon Valley Posts 3,329 Thanks 2 Thanked 232 Times in 225 Posts Why are you using sudo? The ls command doesn't require sudo access. i am getting no o/p as system() is returnning a value of 256 That's because a system call returns the return code of the command you execute. If you want the output of the command use backticks. Code: #!/usr/bin/perl use CGI qw(:standard); print header(), start_html(); print `ls`; print end_html(); Reply With Quote 09-08-2006,07:45 AM #3 ganesh_mak View Profile View Forum Posts Regular Coder Join Date Sep 2005 Posts 113 Thanks 0 Thanked 0 Times in 0 Posts using the backticks also i am not getting the output on the web browser.its blank. and if need to c