I am having a problem reading the exit status of a command or script within a sudo.
returns
"return_code=99"
the $script above is a test script with a "exit 5" at the end. When I run it as the user and echo $? I get a 5.
I have been scanning the forums, trying my own stuff too, but cant seem to find the answer. How do I get the return code from the script (or command) passed out?
Thanks if you can help.
You need to echo it, or stick it in a file, or shove it down a pipe, or send it to syslog, or use it as padding in a ping... point is, $return_code is going to be the "return_code" variable of the shell that launched the sudo, and never the "return_code" variable of the shell you launched via sudo. You need to pass it some other way than as a shell variable.
You can test by doing this:
And sure enough, you'll get "return_code=Luke, I am your father."
i downloaded a text file from metalab.unc.edu called sh.txt and in this reference manual it refers to shell scripting exit status .. at the end of one of the examples that author gave an exit status of 127..
to what does a 127 exit status refer too and what is its purpose in the code.
moxxx68 (1 Reply)
I hope one of you smart people out there can help me with what seems like a real simple questing but I can't quite figure out.
In a script I am doing a cmp on two files. I am trying to check the exit status with an if statement but can't seem to figure out the syntax. If the exit status is 1 I... (4 Replies)
Hi all,
i am writing a script to test if some servers are down and prompt if test positive. i used rlogin and rsh then exit but the script when run, logs into the servers and stays.
pls what can i do to salvage this? or what other options do you suggest? (6 Replies)
Hi all,
I'm running a program which return 1 upon success.
But when encounters problem shell return 's '1' .
How to differentiate between them the shell return value and script return value.
Ex. function fn return '1' if executed successfully and '0' if failed. But when if shell encounters... (1 Reply)
I'm preparing for exam and one of exams is to write own test command...
I wonder if in unix is a command which just returns exit code you specify..
I know I can easily write a function like this:
exStatus() {
return $1
}
-> my question is rather theoretical
thank you! (9 Replies)
hi,
exit status variable $?, returns some digits.
0 ---> succes.
1..126
Failure (the program itself will decide what the numbers mean)
127
Command not found
128..254
The program did not exit normally. (E.g., it crashed, or received a signal)
255
Invalid exit code
well, if $?... (4 Replies)
I have a shell script (#!/bin/sh) that interacts with Appworx and Banner Admin. In my script I want to check the exit status of awrun before continuing. awrun can run for 10 seconds or it can run for over a minute. So my question is, will it go through my if statement before awrun may even be... (2 Replies)
Hi All,
I am trying to create a zip file with all the txt files(these are in large number) in the current directory. I am able to do this operation sucessfully.
After this i want to get the status of the tar command executed and do accordingly. When i am trying with the below code, the status... (3 Replies)
Discussion started by: paddu
3 Replies
LEARN ABOUT XFREE86
s390_sthyi
S390_STHYI(2) System Calls Manual S390_STHYI(2)NAME
s390_sthyi - emulate STHYI instruction
SYNOPSIS
#include <asm/unistd.h>
int s390_sthyi(unsigned long function_code, void *resp_buffer,
uint64_t *return_code, unsigned long flags);
DESCRIPTION
The s390_sthyi() system call emulates the STHYI (Store Hypervisor Information) instruction. It provides hardware resource information for
the machine and its virtualization levels. This includes CPU type and capacity, as well as the machine model and other metrics.
The function_code argument indicates which function to perform. The following code(s) are supported:
0 Return CP (Central Processor) and IFL (Integrated Facility for Linux) capacity information.
The resp_buffer argument specifies the address of a response buffer. If the system call returns 0, the response buffer will be filled with
CPU capacity information. Otherwise, the response buffer's content is unchanged.
The return_code argument stores the return code of the STHYI instruction, using one of the following values:
0 Success.
4 Unsupported function code.
For further details about return_code, function_code, and resp_buffer, see the reference given in NOTES.
The flags argument is provided to allow for future extensions and currently must be set to 0.
RETURN VALUE
On success (that is: emulation succeeded), the return value of s390_sthyi() matches the condition code of the STHYI instructions, which is
a value in the range [0..3]. A return value of 0 indicates that CPU capacity information is stored in *resp_buffer. A return value of 3
indicates "unsupported function code" and the content of *resp_buffer is unchanged. The return values 1 and 2 are reserved.
On error, -1 is returned, and errno is set appropriately.
ERRORS
EFAULT The value specified in resp_buffer or return_code is not a valid address.
EINVAL The value specified in flags is nonzero.
ENOMEM Allocating memory for handling the CPU capacity information failed.
EOPNOTSUPP
The value specified in function_code is not valid.
VERSIONS
This system call is available since Linux 4.15.
CONFORMING TO
This Linux-specific system call is available only on the s390 architecture.
NOTES
Glibc does not provide a wrapper for this system call, use syscall(2) to call it.
For details of the STHYI instruction, see <https://www.ibm.com/support/knowledgecenter/SSB27U_6.3.0/com.ibm.zvm.v630.hcpb4/hcpb4sth.htm>.
SEE ALSO syscall(2)COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the
latest version of this page, can be found at https://www.kernel.org/doc/man-pages/.
Linux Programmer's Manual 2018-02-02 S390_STHYI(2)