为什么??
<VirtualHost *:80>
ServerAdmin admin@mydomain.com
DirectoryIndex index.php
<If "%{SERVER_PROTOCOL} != 'HTTPS'">
Redirect / https://www.mydomain.com:443/
</If>
.....
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
保存,然后重启:
sudo /etc/init.d/apache2 restart
Syntax error on line 4 of /etc/apache2/sites-enabled/000-default:
Invalid command '<If', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.
The Apache error log may have more information.
...fail!
Run Code Online (Sandbox Code Playgroud) 我需要编写一个bash 脚本,并希望它解析格式的无序参数:
scriptname --param1 <string> --param2 <string> --param3 <date>
Run Code Online (Sandbox Code Playgroud)
有没有一种简单的方法可以做到这一点,还是我几乎坚持使用 1 美元、2 美元、3 美元?
编辑
(注意 - 我不需要长参数名称 - 单个字母也可以)
我正在尝试制作安装脚本。我想安装一个.msi文件,Python,然后在安装Python后安装其他东西。我已经看到了如何进行命令行安装。但是,msiexec即使安装仍在运行,也会立即返回。如何从批处理脚本检测 msi 安装的完成?
我一直在使用bash我的大部分系统管理任务。我也懂一点perl。
我应该学习 Python还是Perl更适合系统自动化。到目前为止,从我的经验来看,学习 perl 很容易。
我有一个启动自定义码头服务器的新贵脚本。当我什么sudo start [myservice]都没有发生。随后,将其sudo status [myservice]显示为:[myservice] start/killed, process 3586。
这是 /etc/init/[myservice].conf 中的脚本:
description "[description]"
author "[my name and email]"
start on runlevel [2345]
stop on runlevel [016]
respawn
expect fork
script
sudo -u www-data /path/to/grafserv-start.sh >> /tmp/upstart.log 2>&1
end-script
Run Code Online (Sandbox Code Playgroud)
这里是grafserv-start.sh:
#!/bin/bash
/usr/bin/java -Djetty.port=3070 -jar /path/to/grafserv/trunk/start.jar
echo "Done starting GrafServ"
Run Code Online (Sandbox Code Playgroud)
我尝试将脚本命令的输出重定向到 tmp 日志文件,但从未创建该文件。当我开始它时,我只是挂起,直到我 ^C。另外,我尝试用 strace 运行它,但这给了我很多关于套接字的东西。
我最近有一次编写 shell 脚本的经历,该脚本通过消耗所有资源使服务器崩溃(并损坏了分区)。它连接到一个 cron 作业,运行时间似乎比执行之间的间隔时间更长,随着时间的推移,滚雪球失控。
现在,我已经修改了它以记录其运行状态,并且不会同时运行多次。我的问题是:还有其他简单的方法可以保护脚本免受伤害吗?是否有一个标准的脚本应该做的事情列表,以确保正常运行、不消耗太多资源、优雅地失败、提醒正确的人等?
基本上:我应该避免哪些其他陷阱?
我觉得这应该是一件简单的事情,但我很难弄清楚。
我正在尝试编写一个脚本来监视其中一个 apache 日志文件并采取一些特定的操作。但是我应该如何监视日志文件?
每次将新行写入日志时,我都希望检查该条目以查看它是否与我要查找的内容匹配,以及是否发生了 x。当我手动执行此操作时,我使用了 cat 或 tail -f。我不想通过 cron 每 30 秒运行一次脚本并浏览整个日志(甚至最后 5 行),找出自上次脚本运行以来哪些行是新的,然后是一些事情。
有没有办法只检查日志中的单个新条目?
我正在编写一个 BASH shell 脚本来将目录中的所有文件上传到远程服务器,然后将它们删除。它将通过 CRON 作业每隔几个小时运行一次。
我的完整脚本如下。基本问题是应该确定文件是否上传成功的部分不起作用。无论上传是否成功,SFTP 命令的退出状态始终为“0”。
如何确定文件是否正确上传,以便我知道是删除它还是放任不管?
#!/bin/bash
# First, save the folder path containing the files.
FILES=/home/bob/theses/*
# Initialize a blank variable to hold messages.
MESSAGES=""
ERRORS=""
# These are for notifications of file totals.
COUNT=0
ERRORCOUNT=0
# Loop through the files.
for f in $FILES
do
# Get the base filename
BASE=`basename $f`
# Build the SFTP command. Note space in folder name.
CMD='cd "Destination Folder"\n'
CMD="${CMD}put ${f}\nquit\n"
# Execute it.
echo -e $CMD | sftp …Run Code Online (Sandbox Code Playgroud) 我需要向域中的所有数千台计算机发出 CLI 命令(cmd.exe 或 PowerShell)。出于显而易见的原因,这不会涉及手动执行任务或物理访问每台机器。
这应该怎么做?
我必须通过 PowerShell 检索代理服务器地址和端口,以便我可以使用该Invoke-Webrequest -uri http://some-site.com -Proxy命令。预期的输出应该类似于http://proxy-server.com:port。
我有一个 PowerShell 函数来检索代理服务器地址和端口,所以我们可以在脚本中使用它?
scripting ×10
bash ×4
apache-2.2 ×2
windows ×2
automation ×1
domain ×1
httpd.conf ×1
installation ×1
logging ×1
monitoring ×1
msi ×1
perl ×1
powershell ×1
process ×1
proxy ×1
python ×1
redirect ×1
resources ×1
sftp ×1
ubuntu ×1
upstart ×1
virtualhost ×1