Perl System Error Code 256
Contents |
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 this exit code 256 in unix site About Us Learn more about Stack Overflow the company Business Learn
Exit Code 256 Informatica
more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x c++ system return code 256 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 Executing perl return code 2 shell script with system() returns 256. What does that mean? up vote 8 down vote favorite 3 I've written a shell script to soft-restart HAProxy (reverse proxy). Executing the script from the shell works. But I want a daemon to execute the script. That doens't work. system() returns 256. I have no clue what that might mean. #!/bin/sh # save previous state mv /home/haproxy/haproxy.cfg
Perl System Return Code
/home/haproxy/haproxy.cfg.old mv /var/run/haproxy.pid /var/run/haproxy.pid.old cp /tmp/haproxy.cfg.new /home/haproxy/haproxy.cfg kill -TTOU $(cat /var/run/haproxy.pid.old) if haproxy -p /var/run/haproxy.pid -f /home/haproxy/haproxy.cfg; then kill -USR1 $(cat /var/run/haproxy.pid.old) rm -f /var/run/haproxy.pid.old exit 1 else kill -TTIN $(cat /var/run/haproxy.pid.old) rm -f /var/run/haproxy.pid mv /var/run/haproxy.pid.old /var/run/haproxy.pid mv /home/haproxy/haproxy.cfg /home/haproxy/haproxy.cfg.err mv /home/haproxy/haproxy.cfg.old /home/haproxy/haproxy.cfg exit 0 fi HAProxy is executed with user haproxy. My daemon has it's own user too. Both run with sudo. Any hints? c linux shell daemon share|improve this question asked Sep 17 '10 at 14:40 Jan Deinhard 6,7571553105 add a comment| 4 Answers 4 active oldest votes up vote 17 down vote accepted According to this and that, Perl's system() returns exit values multiplied by 256. So it's actually exiting with 1. It seems this happens in C too. share|improve this answer edited Sep 17 '10 at 14:50 answered Sep 17 '10 at 14:44 Skilldrick 43.1k23129205 1 Thanks! So it's EPERM /* Operation not permitted */ ... but why ... I start the daemon with sudo. –Jan Deinhard Sep 17 '10 at 14:57 1 Perl does not return multiplied exit values. It returns a 16 bit value, with the exit code in the highe
Reply 3 Replies - 25038 Views - Last Post: 13 July 2009 - 03:39 AM #1 Anand Choudhary New D.I.C Head Reputation: 0 Posts: 2 Joined: 06-July 09 wexitstatus Return value 256 Posted 07 July 2009 - 04:28 AM Hi All, I'd perl system call like to know what does return value 256 means in Perl.Is this any error value which describes that program is
Linux Exit Code
not functioning properly? Please help. Regards, Anand Is This A Good Question/Topic? 0 Back to top MultiQuote Quote + Reply Replies To: Return value 256 #2 kmangold D.I.C Head Reputation: 11 http://stackoverflow.com/questions/3736320/executing-shell-script-with-system-returns-256-what-does-that-mean Posts: 167 Joined: 24-June 09 Re: Return value 256 Posted 07 July 2009 - 04:31 AM "Just a note, when using system in perl, it returns the exit code multiplied by 256. So, if a command returns 1, system("command") will return 256. So, to get the real return value, divide by 256." (source)) Was This Post Helpful? 0 Back to top MultiQuote Quote + Reply #3 http://www.dreamincode.net/forums/topic/113508-return-value-256/ Anand Choudhary New D.I.C Head Reputation: 0 Posts: 2 Joined: 06-July 09 Re: Return value 256 Posted 12 July 2009 - 11:25 PM Thanks for your reply. So here I am getting return value 256 means its 1.Actually my code..runs through cronjob and matches system date from a log file which is also being run by cronjob and both code runs per minute by cronjob. So here actual problem is that same code given return value 0 all time but some times it throws return code 256 means 1 i.e. error. Please help..Why same code behaves in different manner. Was This Post Helpful? 0 Back to top MultiQuote Quote + Reply #4 dsherohman Perl Parson Reputation: 227 Posts: 654 Joined: 29-March 09 Re: Return value 256 Posted 13 July 2009 - 03:39 AM Anand Choudhary, on 13 Jul, 2009 - 06:25 AM, said:So here actual problem is that same code given return value 0 all time but some times it throws return code 256 means 1 i.e. error. Please help..Why same code behaves in different manner. Without more information about the code in question, what it does, and the conditions under whic
FORUMSFOR COMPUTER PROFESSIONALS Log In Come Join Us! Are you aComputer / IT professional?Join Tek-Tips Forums! Talk With Other Members Be Notified Of ResponsesTo Your Posts Keyword Search One-Click Access To YourFavorite Forums Automated SignaturesOn Your Posts Best Of http://www.tek-tips.com/viewthread.cfm?qid=1579590 All, It's Free! Join Us! *Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail. Posting Guidelines Promoting, selling, recruiting, coursework and thesis posting is forbidden.Tek-Tips Posting Policies Jobs Jobs from Indeed What: Where: jobs by Link To This Forum! Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.Just copy and paste the BBCode HTML Markdown MediaWiki reStructuredText code below into your site. Perl code 2 Forum at Tek-Tips HomeForumsProgrammersLanguagesPerl Forum Exit codes for system call, work great execpt for rm thread219-1579590 Forum Search FAQs Links MVPs Exit codes for system call, work great execpt for rm Exit codes for system call, work great execpt for rm travs69 (MIS) (OP) 18 Nov 09 10:39 I running system command on a remote box (not my favorite thing to do but I deal with it) and all the commands come back correct exit code 256 except for the rm command.I wrote a simple test scriptCODE#!/usr/bin/perlif (`rm -f /tmp/travis.txt`) { print "success\n"; } else{ print "Failure\n"; }This code prints "Failure" even when it is succesful and it prints "Failure" when it fails :),Any help is appreciated as I don't like to just assume that the rm is working. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions; RE: Exit codes for system call, work great execpt for rm travs69 (MIS) (OP) 18 Nov 09 13:17 So I found a way to get the exit like this $exit_value= $? >> 8;but should I be using that on every command? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions; RE: Exit codes for system call, work great execpt for rm Kirsle (Programmer) 18 Nov 09 19:10 You should generally only use `backticks` when your program actually cares about the text output of the command (its STDOUT). If your program only cares about the exit code, use system() instead, which returns the exit code (and presumably also puts it into $?).CODEif (system("rm -f /tmp/travis.txt") == 0) { print "success\n"; } else{ print "Failure\n"; }The reason your code was