|
|
![]() |
| Thread Tools | Search this Thread |
#1
| |||
| |||
Problem of shell script on Linux I would like to write a small program that enables me to read a value that can be between 0 and 1FFF then use it in a shell-script. Unfortunately, I just discovered that the return code of an executable Linux can not exceed 255. I am especially surprised that the return type of main is an int. Code: int main() { return 257; } Code: #echo $? #1 |
#2
| |||
| |||
Re: Problem of shell script on Linux It depends on the system and shell. Usually, you recover 8 bits signed or not, depending. Do not rely on it for too large values. |
#3
| |||
| |||
Re: Problem of shell script on Linux To retrieve more information, one solution is to write to a file or to stdout, which is quite handy if you use a pipe then. Code: # include <stdlib.h> # include <stdio.h> int main (void) { /* Write to standard output (not bothered to open or close "stdout") */ fprintf (stdout, "12345"); return (0); } |
#4
| |||
| |||
Re: Problem of shell script on Linux the main page for POSIX exit () contains Quote:
|
#5
| |||
| |||
Re: Problem of shell script on Linux 256 values for a shell that is more than enough to take decisions (in practice, it is 0 (OK) or 1 (ERROR)). If you need to return a specific value (text), uses a text file. It can then be read by the application who needs it. You can also get the value for stdout and stdin recover directly from another application using the 'pipe' (usually '|' in the current system ...) Use classic MS-DOS: Quote:
__________________ The FIFA Manager 2009 PC Game |
![]() |
|
Tags: linux, shell script |
Thread Tools | Search this Thread |
|
![]() | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Linux shell script to find duplicate images | Savious | Operating Systems | 6 | 21-10-2010 05:26 AM |
shell script SSH not working | Lilya | Software Development | 9 | 16-10-2010 01:53 AM |
Shell script with sed | Ameeryan | Software Development | 5 | 23-12-2009 02:29 PM |
Linux Shell Script to make CD/DVD Image mounting possible | kelfro | Software Development | 2 | 04-03-2009 03:18 PM |
Shell script Problem in JAVA programing | Pandya | Software Development | 3 | 04-03-2009 08:26 AM |