小编Jam*_*mes的帖子

错误的数组下标

我对Shell比较陌生,我一直在尝试在Shell中使用数组,但效果不佳.我正在尝试编写一个脚本来暂停OpenVZ容器,如果它们在一段时间内达到一定的带宽阈值.

我的剧本:

#!/bin/bash
#Thresholds are in bytes per second and count1 must > count2
LOGDIR="/var/log/outbound_ddos"
SECS=10
THRESHOLD1=65536000
COUNT1=10
THRESHOLD2=117964800
COUNT2=2

while [ 1 ]
do
    for veid in $(/usr/sbin/vzlist -o veid -H)
    do      
        # Create the log file if it doesn't already exist
        if ! test -e $LOGDIR/$veid.log; then
            touch $LOGDIR/$veid.log
        fi

        # Parse out the inbound/outbound traffic and assign them to the corresponding variables     
        eval $(/usr/sbin/vzctl exec $veid "grep venet0 /proc/net/dev"  |  \
            awk -F: '{print $2}' | awk …
Run Code Online (Sandbox Code Playgroud)

arrays bash shell

8
推荐指数
1
解决办法
2万
查看次数

Symfony2每个主机访问控制

我正在尝试在Symfony 2.2中实现主机路由.我已将路由添加到app/config/routing.yml,但app/config/security.yml中的安全限制正在重定向请求.

例如,我有(www.)domain1.com和{subdomain} .domain2.com.我希望security.yml中的安全限制仅适用于{subdomain} .domain2.com(我的应用),而不适用于(www.)domain1.com(我的主页).

怎么能实现这一目标?我正在寻找这样的东西:

security:
    firewalls:
        home_page:
            host:  (www.)domain1.com
            security: false
Run Code Online (Sandbox Code Playgroud)

security url-routing symfony

3
推荐指数
1
解决办法
2274
查看次数

在Doctrine中反转布尔值

我正在使用Symfony2和Doctrine查询构建器.有没有一种简单的方法来反转数据库中的布尔值?

我试过这个没有运气:

    $query->update('AppMonitorBundle:Monitor', 'm')
            ->set('m.isActive', '!m.isActive')
            ->where('m.id = :monitor')
            ->setParameter('monitor', $monitor)
            ->getQuery()
            ->execute()
    ;
Run Code Online (Sandbox Code Playgroud)

我认为它可以在SQL中工作,但它给了我:

[Syntax Error] line 0, col 51: Error: Expected Literal, got '!'
Run Code Online (Sandbox Code Playgroud)

代替!对于NOT,给出相同的结果.

symfony doctrine-orm

2
推荐指数
1
解决办法
1089
查看次数

Bash删除</ html>之后的所有内容

我的一个客户网站遭到黑客入侵,每个文件都有iframe注入.但是,iframe注入总是在结束</html>标记之后.

是否有一种简单的方法使用Bash删除</html>标签后使用像sed这样的东西?

例如:

</html>
p
<nofollow><iframe src="http://xxxxx.com/local.html" width="0" height="0" frameborder="0"></iframe></nofollow>
p
<nofollow><iframe src="http://xxxxx.com/local.html" width="0" height="0" frameborder="0"></iframe></nofollow>
Run Code Online (Sandbox Code Playgroud)

replace sed

1
推荐指数
1
解决办法
269
查看次数

标签 统计

symfony ×2

arrays ×1

bash ×1

doctrine-orm ×1

replace ×1

security ×1

sed ×1

shell ×1

url-routing ×1