shell (check return of each line)(PIPESTATUS[@])and sudoer
shell result from cmdline
echo $?
if 0 then success ;else failure
(shell 执行每部返回值,rm -rf 错误,打包不能覆盖)
我们知道,linux命令行上一个命令的退出码放在了$?环境变变中,但是,如果这个命令是一串管道符连接和多个命令,怎么知道每个命令的退出码?你可以 使用 PIPESTATUS环境变量。比如这个测试:true | false | true; echo "${PIPESTATUS[@]}"
have a tty to run sudo
sorry, you must have a tty to run sudo,后来,在网上了解到可以如下解决:
requiretty,修改为 #Defaults requiretty,表示不需要控制终端。
requiretty,修改为 Defaults:nobody !requiretty,表示仅 nobody 用户不需要控制终端。
Defaults:%nobody !requiretty,表示仅 nobody 组不需要控制终端。
requiretty
那个就可以了。表示在执行的时候不打开终端。但是,有的shell必须要有终端才可以执行。这样显然是不行的。后来,又找到一片文章才搞定。下面为抄录的,仅为记录以后使用。
但可能这个程序需要控制终端, 这这么办呢?
可是中间有个程序(旧的systemtap)使用了sudo
但这样很对用户不友好啊)
a tty to run sudo
那就是你的系统的sudo配置文件允许sudo可以在这个,
requiretty)
`/dev/tty' for reading: No such device or address
所以应该使用能创建(伪)控制终端的程序来启动你的程序如: script, expect
ls" /dev/null
sudo ls; expect'
0 /dev/tty' /dev/null
head -c 0 /dev/tty; expect'
组合使用有着奇怪的bug, 我这段时间非常的depression,
都是大材小用了
shell (check return of each line)(PIPESTATUS[@])and sudoer的更多相关文章
- shell (check return of each line)and sudoer
shell result from cmdline echo $? if 0 then success ;else failure (shell 执行每部返回值,rm -rf 错误,打包不能覆盖) 解 ...
- Shell脚本:while read line无法读取最后一行的问题
[1]Shell脚本:while read line无法读取最后一行的问题 刚刚利用shell脚本处理日志文件时,发现了一个问题:while read line无法读取到最后一行 通过编辑器可以看到待 ...
- SAP(ABAP):STOP,EXIT,CHECK,RETURN,REJECT,CONTINUE
Stop 命令使用该命令的程序位置INITIALIZATION, AT SELECTION-SCREEN, START-OF-SELECTION和GET 事件中处理说明1. 当在INITIALIZAT ...
- learning shell check requires root privileges
[Purpose] Shell script check requires root privileges [Eevironment] Ubuntu 16.04 bas ...
- learning shell check host dependent pkg
[Purpose] Shell script check host dependent pkg [Eevironment] Ubuntu 16.04 bash env ...
- Shell check IP
#! /bin/bash checkip() { if echo $1 |egrep -q '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3 ...
- 如何在Windows下开发Python:在cmd下运行Python脚本+如何使用Python Shell(command line模式和GUI模式)+如何使用Python IDE
http://www.crifan.com/how_to_do_python_development_under_windows_environment/ 本文目的 希望对于,如何在Windows下, ...
- Google Shell Style Guide
转自:http://google.github.io/styleguide/shell.xml Shell Style Guide Revision 1.26 Paul Armstrong Too m ...
- KoaHub.JS用于Node.js的可移植Unix shell命令程序代码
shelljs Portable Unix shell commands for Node.js ShellJS - Unix shell commands for Node.js Shell ...
随机推荐
- Selenium - Switch & Select Api
一.多表单切换 driver.switch_to.frame() iframe :直接将一个html 页面嵌入另一个html 页面中 switch_to.frame() 默认可以直接取表单的id ...
- PHP截取中文字符串不出现?号的解决方法[原创]
PHP截取中文字符串不出现?号的解决方法[原创] 大 | 中 | 小 [不指定 -- : | by 张宴 ] [文章作者:张宴 本文版本:v1. 最后修改: 转载请注明出处:http://blog.z ...
- iOS开发之使用AFN上传图片
//1.创建管理者对象 AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; manager.responseSerializ ...
- linux命令之fuser
Usage: fuser [ -a | -s | -c ] [ -n SPACE ] [ -SIGNAL ] [ -kimuv ] NAME... [ - ] [ -n SPACE ] [ -SIGN ...
- python操作word之pywin32的安装
PyCharm 2016.2 官网中文汉化破解版 注册码 http://idea.lanyus.com/ 首先下载安装win32com,下载32位的,不然安装的时候可能检测不到python https ...
- xeno 实时性能测试 在100us的采样周期的测试数据
1 xeno 用户层测试时间: root@sama5d3-linux:/usr/bin latency -t0 -T25 -p100== Sampling period: 100 us== Test ...
- div允许用户输入
主要是用到contenteditable属性,就可以用div让用户输入了 <div id="guo" style="width:500px; height:200p ...
- Entity Framework(四):使用DbModelBuilder API创建表结构
DbContext类有一个OnModelCreating方法,它用于流利地配置领域类到数据库模式的映射.下面我们以fluent API的方式来定义映射.首先,先将Product类注释掉,重新编写该类, ...
- php 判断查询结果是否为空
select count(people) c from people where people='乐乐' 上面这条sql就是原理 php利用代码 <?php $p=$_POST['p']; $c ...
- Python安装相关的机器学习库以及图像处理库
安装 sudo apt-get install python-scipy sudo apt-get install python-numpy sudo apt-get install python-m ...