Articles of bash

永不停息​​的屏幕。

我的目标是从屏幕上的bash开始一堆进程,但是屏幕不应该在运行进程结束或者因错误而停止之后终止。 所以即时通讯会做一些像: 为屏幕(screen.conf)做一个configuration文件: screen -t myscreen0 0 myscript.sh; screen -t myscreen1 1 myscript.sh; screen -t myscreen2 2 myscript.sh; screen -t myscreen2 2 myscript.sh; 用screen -c screen.conf启动它 但是,现在当脚本结束或出现错误屏幕正在终止。 我发现,僵尸参数可以帮助我,但我现在不怎么使用它(在手册页描述不佳)。 或者也许有另一种方法来解决这个问题。

Bash函数,返回值和error handling

我试图把我的头围绕着Bash,并且认为我已经变得相当远了。 我真的不明白的是error handling… 我有以下脚本: set -e set -u DOWNLOADED_ARTIFACT=$(downloadApplication "$WEB_GROUP") if [[ $? != 0 ]]; then exit 1 fi 即使downloadApplication函数失败(我现在的预期结果),脚本也不会失败。 捕获到一个variables的输出时,我不知道如何检查。 如果我不把它放回到一个variables,它会工作,并按预期失败: downloadApplication "$WEB_GROUP" if [[ $? != 0 ]]; then exit 1 fi 我有什么select? 谢谢。

Perl命令行+在文件中的string之前添加PATH

我想通过perl命令行(perl命令行必须在我的bash脚本中)在文件中添加PATH – / usr / local / bin / perl befporestring,我有solaris机器 在$ APIDIR / scan.pl文件之前和char之后添加 – / usr / local / bin / perl目标 – “ 请咨询如何在$ APIDIR / scan.pl之前添加PATH – / usr / local / bin / perl ,最后我会得到 新线 – my $APIDIR="/usr/local/cp/api"; remark – this line shouldn't be change my $script="/usr/local/bin/perl $APIDIR/scan.pl"; 代替 […]

如何使用bash在centos 5.8 64bit上安装imagick的最新版本

如何在centos 5.8 64bit下使用bash for php 5.4下载并安装imagick的最新版本。 >yum info php Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.ellogroup.com * epel: mirror01.th.ifl.net * extras: mirror.ellogroup.com * updates: mirror.ellogroup.com Installed Packages Name : php Arch : x86_64 Version : 5.4.3 Release : 1.el5.remi Size : 8.8 M Repo : installed Summary : The PHP […]

如何在Redhat上使用LiveReload正确地SSH端口?

参考这个页面: http://feedback.livereload.com/knowledgebase/articles/86280-if-you-edit-files-directly-on-your-server 它说你可以使用这个命令远程端口转发35729的LiveReload特定端口: ssh -L 35729:127.0.0.1:35729 mylogin @ myremoteserverIP 当我运行-v选项时,我得到: debug1: Local connections to LOCALHOST:35729 forwarded to remote address 127.0.0.1:35729 debug1: Local forwarding listening on ::1 port 35729. debug1: channel 0: new [port listener] debug1: Local forwarding listening on 127.0.0.1 port 35729. debug1: channel 1: new [port listener] debug1: channel 2: new [client-session] debug1: Entering […]

从php脚本发送输出从bash脚本调用到syslog

从php脚本发送输出从bash脚本调用到syslog 我试图创build一个bash脚本(由cron作业调用)调用一个php文件(我没有)。 调用php文件很简单。 PHP脚本输出了很多东西到标准输出,我想redirect输出从PHP脚本logging器,以便我可以监视我的远程系统日志服务器的进度。 我试过类似的东西: PHP_SCRIPT_PATH="/some/path" ME= basename $0 LOGGER="logger -p cron.notice -t $ME" cd $PHP_SCRIPT_PATH php the_php_script.php &> eval $LOGGER 还试过: php the_php_script.php | eval $LOGGER 但是都没有工作。 我考虑过的另一个可能的解决scheme是将输出从php脚本输出到日志文件,然后让另一个bash脚本读取该文件并将每行写入logging器。 但我想有一个脚本,它做的一切:) 任何人都可以请帮忙?

将远程authorized_keys文件的列表分配给本地variables

我想分配一个远程授权密钥文件列表到本地variables。 INCLUDE=$(ssh myhost.mydomain.com "for Z in `awk -F : '{print $1}' /etc/passwd`; do INCLUDE+=\"/home/${Z}/.ssh/authorized_keys \"; done; echo $INCLUDE") 我怎样才能正确地转义上面的命令,使其成为一个有效的请求?

Bash脚本手动运行,但在crontab上失败

我是shell脚本的新手。 我写了一个shell脚本来做MySQL数据库的增量备份。脚本是可执行的格式,手动执行时运行成功,但通过crontab执行时失败。 Crontab条目是这样的:* / 1 * * * * /home/db-backup/mysqlbackup.sh 下面是shell脚本代码 – #!/bin/sh MyUSER="root" # USERNAME MyPASS="password" # PASSWORD MyHOST="localhost" # Hostname Password="" #Linux Password MYSQL="$(which mysql)" if [ -z "$MYSQL" ]; then echo "Error: MYSQL not found" exit 1 fi MYSQLADMIN="$(which mysqladmin)" if [ -z "$MYSQLADMIN" ]; then echo "Error: MYSQLADMIN not found" exit […]

显示不同条目的bash_history文件和历史命令

我正在使用OS X上的terminal应用程序尝试清除我的命令历史logging。 我的$HOME/.bash_history文件中的条目与history命令返回的内容不匹配。 echo $0命令告诉我,我的terminal会话正在使用bash shell( -bash ),所以我期望这些是相同的。 此外, history -c命令只会清除terminal应用程序中使用history命令查看的history ,但不会影响$HOME/.bash_history文件的内容。 请有人帮忙解释我的误解?

ssh远程执行多个文件

我有两个本地文件,一个包含variables定义的config.sh ,另一个包含bash脚本的script.sh 。 本地,我可以这样做: source config.sh; bash script.sh 我正在通过SSH寻找相同的东西,到目前为止,我得到了这个工作: ssh user@host 'bash -s' < script.sh 但我不知道是否应该使用cat或一些inputpipe道<(…)来同时执行config.sh和script.sh。 什么是最好的,干净的方式来执行多个命令,需要一些内容与sshpipe道?