I want to force output when CentOS 7 error is not standard output

Asked 2 years ago, Updated 2 years ago, 53 views

CentOS 7 may not provide a standard output.

For example, ifup or ifdown results are
There is no output, but it is actually not working properly.

Currently,

ifup ppp0||echo "Error Occurred"

You can only detect what is happening as shown in .

Is there any way to force standard output?

linux centos

2022-09-29 20:27

1 Answers

Based on the communication in the comments, what I really want to do is answer with the assumption that ifup I want to detect and receive any errors during execution.

In addition to the ifup command, Linux commands typically set a value for the special variable $? that indicates the success or failure of a command execution called exit status.

  • Successful:0
  • Abnormal exit: 1 (or a number other than 0 depending on the command or error type)

The ifup command is a shell script (as noted in the comment) and calls other scripts sequentially as you follow the action, but the exit status seems to have been set to the same value as described above, so you should use this value.


2022-09-29 20:27

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.