如何在下面的脚本中添加“expect”超时? 我想把它设置为120秒。 #!/bin/bash HOST="localhost" USER="myuname" PASS="mypassword" VAR=$(expect -c " spawn ssh $USER@$HOST expect \"password:\" send \"$PASS\r\" expect \"\\\\$\" send \"ls\r\" expect -re \"$USER.*\" send \"logout\" ") echo "===============" echo "$VAR"
我正在编写一个脚本,我想要启动mysql_secure_installation脚本并在每个提示符处提供相应的答案。 我尝试使用这样的回声: echo -e "\n\n$db_pass\n$db_pass\n\n\n\n\n" | /usr/bin/mysql_secure_installation 它不完全工作。 它似乎正确回答了最后5个问题,但它没有正确回答前3个(这是在CentOS 6.5框中)。 这是输出: In order to log into MySQL to secure it, we'll need the current password for the root user. If you've just installed MySQL, and you haven't set the root password yet, the password will be blank, so you should just press enter here. stty: […]
我正在运行这个命令来找出最近10分钟被修改的文件 find / -fstype local -mtime -10m 但每次都会出现以下错误 find: missing argument to `-mtime' 上面有什么问题?
我试图find这三行: <!– <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> –> 并将其replace为: <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> 当我尝试 sudo sed -i 's:<!– <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> –>:<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />:' /myfile.xml 它没有find它,我也试图把它\ n,但它仍然没有工作: sudo sed -i 's:<!–\n <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />\n –>:<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />:' /myfile.xml 这些不会抛出任何错误,只是不注销行。 任何build议将有助于感谢!
我想改变当前正在运行的脚本的级别: #!/bin/bash nice_it ( ) { nice ps -o "%p %r %y %x %n %c %a" } nice_it 这是行不通的,因为nice试图改变由它启动的命令的好水平。 是否有可能在bash中实现这一点?
我有一个深层的目录结构,有大量的文件(大约1M)。 我想对每个执行一个命令。 (在我的情况下,这些文件是我想运行optipng的png。) 我试过这个: find . -name *.png | xargs sudo optipng -o2 但得到错误argument list too long 。 我假设xargs应该能够处理这个问题,而且我的语法一定有问题。
我得到一个需要sudo的脚本,但脚本必须按照原始用户设置参数,例如: chown "${USER}:${USER}" dir 如果我把它设置在sudo下面,我只需要chmod root:root ,这没有帮助。 那么我怎么才能得到sudo之前的用户名?
如果出现问题,我需要脚本给pipe理员发送电子邮件,而公司只使用Gmail。 在几篇博文的指导下,我可以使用.mailrc文件设置mailx。 首先是nss-config-dir的错误,我通过从firefox目录复制一些.db文件来解决这个问题。 到./certs并且在mailrc中瞄准它。 邮件已发送。 但是,上面的错误出现了。 奇迹发生了,.db中有一个Google证书。 它显示了这个命令: ~]$ certutil -L -d certs Certificate Nickname Trust Attributes SSL,S/MIME,JAR/XPI GeoTrust SSL CA ,, VeriSign Class 3 Secure Server CA – G3 ,, Microsoft Internet Authority ,, VeriSign Class 3 Extended Validation SSL CA ,, Akamai Subordinate CA 3 ,, MSIT Machine Auth CA 2 ,, Google […]
我刚刚跑了 cat /opt/webapplications/Word/readme.log | grep -v 'Apple' 我得到了我期待的cli上的输出,这是readme.log中所有不包含“ Apple ”的行… 接下来我跑了… cat /opt/webapplications/Word/readme.log | grep -v 'Apple' > /opt/webapplications/Word/readme.log 但是,/ /opt/webapplications/Word/readme.log是空白的。 任何人都可以向我解释为什么发生这种情况,或者我应该这样做的正确方法吗?
你如何做出逃避的工作,使&实际上在后台运行第一个命令? # foo param1 param2 >> run.out &; tail -f run.out