Shell result from CmdLine
echo $?
If 0 then success; else failure
(Shell executes each return value, RM-RF error, package cannot overwrite)
Solve Sudo:sorry, you must has a TTY to run sudo a few days ago encountered a problem, call another shell in one terminal, is always unable to execute, and then catch the error message for Sudo:sorry, you must ha ve a TTY to run Sudo, later, learned on the internet can be resolved as follows: 1. Edit/etc/sudoers 1) Defaults requiretty, modified to #Defaults requiretty, indicates that no control terminal is required. 2) Defaults requiretty, modified to Defaults:nobody!requiretty, indicates that only nobody users do not need to control the terminal. If modified to Defaults:%nobody!requiretty, indicates that only the nobody group does not need to control the terminal. just comment out) Defaults requiretty that's it. Indicates that the terminal is not opened at execution time. However, some shell must have a terminal to be able to execute. This is obviously not going to work. Later, found a piece of article to take care of. The following is transcribed, used only for later recording. Some programs/scripts may be executed in an environment without terminal control (such as when the system starts the service, Daemon, or SETSID-initiated programs, etc.) but maybe this program needs to control the terminal, so this is it? As our example: We start a service at Linux startup, But in the middle there is a program (old Systemtap) using sudo but sudo need to control the terminal (of course can be modified by sudo configuration file, but this is very unfriendly to the user AH) Example: (Setsid startup program will lose control terminal) # Setsid sudo lssudo : Sorry, you must has a TTY to run sudo (if your system does not output this sentence, that is, the sudo profile of your system allows sudo to be available in this, make sure that the defaults requiret are set up TY) when there is no control interruption, open the control terminal is the effect: # Setsid Head-c 0/dev/ttyhead:Cannot open '/dev/tty ' for reading:no such device or address in order to solve this problem, you should use the program that can create (pseudo) control terminal to start your program such as: script, expect such as: # Sets ID script-c "sudo ls"/dev/null or: # setsid expect-c ' spawn sudo ls; Expect ' #打开控制终端成功: # setsid script-c ' head-c 0/dev/tty '/dev/null # setsid expect-c ' spawn head-c 0/dev/tty; Expect ' but setsid with the script combination with a strange bug, I this time very depression, so to script, expect, are overqualified
Shell (check return of each line) and Sudoer