Articles of bash

IO错误在CIFS OSX的无匹配glob – > debian jessie mount

在Debain Jessie 8.2中,当samaba cifs mount没有匹配时,在bash使用通配符/ glob(至less是*和? )会导致input/output error 。 在其他文件系统上,预期No such file错误。 在archlinux盒子上的同样的samaba安装点并且没有io错误。 Archlinux机器的mount.cifs理解mapposix 。 我怀疑jessie上的mount.cifs不允许/理解mapposix与此有关。 是否有绕过io错误的* ? ## works as expected on cifs mount from centos server ls /data/Luna1/*adfadf* # ls: cannot access /data/Luna1/*adfadf*: No such file or director ### unexpected io failure on osx mounted on debian mkdir /Volumes/Phillips/testdir ## no files match […]

无法从PHP运行生成的python(selenium)脚本

我有一台用于无头seleniumtesting的Ubuntu机器。 我通过PHP在/var/www/tmp/random123name.py中生成一个python脚本并执行它们。 这个脚本在从命令行用户运行时工作,从web(apache www-data:www-data user)运行失败。 该脚本回忆一些系统/ python模块: from selenium import webdriver from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from time import sleep, strftime import os, json from pyvirtualdisplay import Display 此代码返回1: $python = "sudo /usr/bin/python /var/www/tmp/random123name.py"; exec($python, $output, $return); echo "OUT<pre>".print_r($output,1)."</pre>"; #returns empty echo "RET<pre>".print_r($return,1)."</pre>"; #returns 1 我用这种方式修改了/ […]

如何编写一个陷阱SIGTERM的bash脚本,并立即杀死进程和所有subprocess

我有这个脚本: #!/bin/bash set -e #WHAT SHOULD I WRITE HERE? sleep 60 # this is for testing #java … | logger # this is what will be in the real script 我希望能够通过发送myscript SIGTERM来杀死myscript和所有它的subprocess: $ kill -s SIGTERM 5929 当我运行它,我看到在ps fuxa : me 3640 0.0 0.1 108416 2100 pts/2 Ss 09:38 0:00 \_ /bin/bash me 5929 0.0 […]

sudo / bin / bash和sudo su访问root的区别

我知道在terminal上至less有两种方法可以升级到root权限,而且真的好奇,对于可以访问或者不能访问的内容是否存在差异/差异。 另外,是否有任何安全的好处或缺点?

如何显示init输出到tty7(或主tty)

我已经在linux服务器上创build了我的第一个初始化脚本(如果添加了任何信息的话,ubuntu会检查更新,下载并在每个小时执行一次)。 init文件如下: /etc/init/updater.conf start on (filesystem and stopped udevtrigger) stop on runlevel [06] console output respawn script chvt 6 chvt 7 while true; do # code to check update … if [ should_update ]; then # Download the script chmod +x /path/to/script.sh bash /path/to/script.sh rm /path/to/script.sh fi echo 'Rechecking for updates in 1h…' sleep 1h […]

如何获得在aws实例中执行的python脚本的输出

我正在尝试使用boto自动化aws实例设置。 我有一个python脚本,我将在这个实例中执行ssh。 在ssh之后,我正在使用shell命令(python -c“filename”)执行远程python文件中的python函数,直到python执行完成,我才能得到输出。 我们如何从远程python脚本获得实时输出?

当LSB停止时,在屏幕上运行命令

我试图让一个Bukkit服务器作为一个服务在屏幕上运行,从一个LSB​​脚本启动,但我不能让它停止正确。 我基本上希望它做的是重新挂接屏幕并发送一个“停止”命令到服务器控制台,所以它保存了一切,而不是被杀死,但“sudo服务bukkit停止”似乎没有做任何事情与我的脚本。 如果我在terminal重新连接屏幕,并在“Bukkit”控制台上input“stop”,它似乎仍然停止。 任何人都知道问题是什么? 我的init.d脚本如下… #!/bin/bash ### BEGIN INIT INFO # Provides: scriptname # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start daemon at boot time # Description: Enable service provided by daemon. ### END INIT INFO cd /etc/minecraftbukkit case $1 in […]

Linux重新启动ramdisk传输文件

我创build了一个tmpfs虚拟硬盘,通过/etc/fstab启动。 ramdisk应该用来为在机器上运行的apache web服务器提供内容。 有没有简单的方法将文件传输到非易失性介质(可能来自)? 或者我只需要创build一个必须设置为cron作业(要运行@reboot )的bash脚本,并执行cp -R /location/* /destination ?

为什么我的configuration文件查找/usr/local/etc/profile.global(NIS)

我的Ubuntu ID由NIS / yellowpagepipe理。 出于某种原因,当我login时,我收到这个消息。 cat@local:~$ ssh catserver cat@catserver's password: Welcome to Ubuntu 15.10 (GNU/Linux 4.2.0-25-generic x86_64) Last login: Thu Apr 21 11:46:22 2016 from xxxx -bash: can't find configuration file /usr/local/etc/profile.global; exiting. Connection to catserver closed. 如果我在这个服务器上创build一个空的/usr/local/etc/profile.global文件,那么它就可以工作。 但我不明白为什么我的bash脚本试图加载这个文件。 我search了这些文件: /etc/profile , /etc/bashrc , ~/.bash_profile和~/.bashrc 。 而且他们都没有代码来加载profile.global 。 我该如何解决这个问题? 这是我的bashconfiguration文件问题或一些NIS问题?

如何从另一个文件夹运行./configure?

我正在编写一个应该从源代码编译并安装它的一个可靠的手册。 在检查我的手册时,我试着手动运行相关命令来检查它们的输出。 所以,在我的有力的游戏书中,我已经configuration了这个: – name: Configure kafkacat command: . {{ install_dest }}/configure arg1 args: enable_json: "–enable-json" sudo: yes 但在运行剧本之前,我手动运行: . /tmp/kafkacat/configure –enable-json . /tmp/kafkacat/configure –enable-json这应该相当于在当前目录中运行./configure ,但是命令失败,并且出现错误。 那么怎么做呢? 提前致谢