Articles of bash

insserv:警告:脚本'uwsgi'缺lessLSB标签和覆盖

这是我的代码: #!/bin/bash daemon="$APPVENV/bin/uwsgi" args="–emperor $APPCONF/uwsgi/app.ini" pid="$APPDIR/emperor.pid" case "\$1" in start) echo "Starting uwsgi" start-stop-daemon -m -p \$pid –start –exec \$daemon — \$args ;; stop) echo "Stopping script uwsgi" start-stop-daemon –signal INT -p \$pid –stop \$daemon — \$args ;; reload) echo "Reloading conf" kill -HUP \$(< \$pid) ;; *) echo "Usage: /etc/init.d/uwsgi {start|stop|reload}" exit 1 ;; […]

用stdin超时一个脚本

我需要这样的东西: timeout -k 4 cat file | myscript.sh 但我得到这个错误: timeout: invalid time interval 'cat' Try 'timeout –help' for more information. 我想将标准input传递给myscript.sh,并在执行4s后终止。

Rackspace Ubuntu中的Shellshock保护

我正在尝试在Rackspace中更新我的Ubuntu 13.10服务器以避免Shellshock错误,但是它不起作用。 这是我在做什么: $ sudo apt-get update && sudo apt-get install –only-upgrade bash 它说: bash is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 35 not upgraded. $ env VAR='() { :;}; echo Bash is vulnerable!' bash -c "echo Bash Test" Bash is vulnerable! Bash Test 我做错了什么?

CentOS 7:获取接口IP号码

我试图在CentOS 7映像中自动填充/ etc / issue(这将是一个模板,并且一眼就能很容易地识别出结果的虚拟机)。 我在/ sbin / ifup-local中有以下内容: #!/斌/庆典 cd / etc; 取消链接./issue; 睡觉1; issue_original =“$(cat ./issue-original)”; show_ip =“$(ip addr show | awk'$ 1 ==”inet“&& $ 2!〜/ ^ 127 / {print”\ t“$ 2}')”; 合伙人/组织 echo -e“$ {issue_original} \ n \ n \ t当前IP号码:\ n \ t =================== \ n $ {show_ip} \ n”> 。/问题 […]

CentOS无法更新Bash

我试图修补我的服务器对Shellshock漏洞的问题。 但是,我无法将Bash更新为安全版本,这些是我得到的结果: # yum update bash Loaded plugins: fastestmirror, security Loading mirror speeds from cached hostfile Skipping security plugin, no data Setting up Update Process No Packages marked for Update 我正在运行CentOS 5.10,并且命令yum repolist all都显示更新回购已启用。 当前安装的Bash版本是3.2-32.el5_9.1。 这个命令显示我的服务器容易受到Shellshock的攻击: # env x='() { :;}; echo vulnerable' bash -c 'echo hello' vulnerable hello

ShellShock – 无法更新CentOS 5.7

[user@server1 ~]$ wget http://mirror.centos.org/centos-5/5/updates/x86_64/RPMS/bash-3.2-33.el5.1.x86_64.rpm [user@server1 ~]$ sudo rpm -Uvh bash-3.2-33.el5.1.x86_64.rpm warning: bash-3.2-33.el5.1.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID e8562897 Preparing… ########################################### [100%] package bash-3.2-33.el5.1.x86_64 is installed [user@server1 ~]$ exit [user@server1 ~]$ rpm -q bash bash-3.2-32.el5 bash-3.2-33.el5.1 [user@server1 ~]$ bash –version GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu) Copyright (C) 2005 Free Software Foundation, Inc. [user@server1 ~]$ […]

小时Clamscan cron脚本在阅读文件列表中失败

我有这段代码位于/etc/cron.hourly/hourlyclamscan。 #!/usr/bin/bash # Create Hourly Cron Job With Clamscan # Directories to scan SCAN_DIR=/home/transmission/Downloads # Temporary file LIST_FILE=`mktemp /tmp/clamscan.XXXXXX` # Location of log file LOG_FILE=/var/log/clamav/hourly_clamscan.log # Make list of new files /usr/bin/find "$SCAN_DIR" -type f -mmin -60 -fprint ${LIST_FILE} # Scan files and remove infected /usr/bin/clamscan -i -f ${LIST_FILE} –remove > $LOG_FILE # If there […]

我怎样才能在Linux命令行上返回一个特定的退出码?

我有一个程序来控制一个远程机器上运行ssh的长时间运行的进程。 通常情况下,我会在这个过程中断开连接,所以我改变了这样的调用: my-long-cmd 至 my-long-cmd; echo $? > /tmp/my.cmd.status 这工作; 该进程本身启动了一些subprocess等,所以即使连接中断,它仍然继续运行,我的脚本可以定期重新连接到机器,并检查文件是否存在(从而机器已完成configuration),如果是的话,看看它是否成功退出。 但是,这也意味着如果我没有断开连接,我将永远只能看到通过SSH库echo命令的退出状态。 我试图做一些像echo $? && return $? echo $? && return $? 但return只能在脚本中使用。 是否有捷径可寻?

bash:类似quotemeta()的模式字符?

背景 我知道bash的各种string操作function。 此外,我知道我可以逃避特殊模式字符与反斜杠\ 。 例如: # x is a literal string 'foo*bar' x="foo*bar" # prints "*bar". echo "${x##foo}" # prints nothing, since the '*' is interpreted as a glob. echo "${x##foo*}" # prints "bar", since I escaped the '*'. echo "${x##foo\*}" 问题 以上都很好,很好。 问题是当模式从其他地方进入时,它可能没有*和其他特殊符号字符转义。 例如: prefix="foo*" … later, in some faraway code … x="foo*bar" # […]

环境variables在Python中不可用

关于环境variables,我有一个非常有趣的问题,并且使用Googlesearch并没有显示出任何有意义的结果: $ echo $BUCKET && python -c "import os; print os.environ['BUCKET']" mule-uploader-demo Traceback (most recent call last): File "<string>", line 1, in <module> File "/usr/lib/python2.7/UserDict.py", line 23, in __getitem__ raise KeyError(key) KeyError: 'BUCKET' 所以我有一个在bash中可用的环境variables,但不是在python中。 这怎么可能发生,我该如何解决? 这里是一些额外的细节: 环境variables通过source envvars.sh命令设置 envvars.sh文件仅包含如下所示的行: KEY=value 我已经在bash和zsh中转载了这个 如果我做一个export BUCKET=$BUCKET ,它的工作