Search code examples
bashshellcommand-lineopenvz

Bash commands putting out extra information which results into issues with scripts


Okay, hopefully I can explain this correctly as I have no idea what's causing this or how to resolve this.

For some reason bash commands (on a CentOS 6.x server) are displaying more information than "normally" and that causes issues with certain scripts. I have no clue if there is a name for this, but hopefully someone knows a solution for this.

First example.

Correct / good server:

[root@goodserver ~]# vzctl enter 3567
entered into CT 3567
[root@example /]#

(this is the correct behaviour)

Incorrect / bad server:

[root@badserver /]# vzctl enter 3127
Entering CT
entered into CT 3127
Open /dev/pts/0
           [root@example /]#

With the "bad" server it will display more information as usual, like:

  • Entering CT
  • Open /dev/pts/0

It's like it parsing extra information on what it's doing.

Ofcourse the above is purely something cosmetic, however with several bash scripts we use, these issues are really issues.

A part of the script we use, uses the following command (there are more, but this is mainly a example of what's wrong):

 DOMAIN=`vzctl exec $VEID 'hostname -d'`

The result of the above information is parsed in /etc/named.conf.

On the GOOD server it would be added in the named.conf like this:

zone "example.com" {
    type master;
    file "example.com";
    allow-transfer {
            200.190.100.10;
            200.190.101.10;
            common-allow-transfer;
    };
};

The above is correct.

On the BAD server it would be added in the named.conf like this:

zone "Executing command: hostname -d
example.com" {
    type master;
    file "Executing command: hostname -d
example.com";
    allow-transfer {
            200.190.100.10;
            200.190.101.10;
            common-allow-transfer;
    };
};

So it's add stuff of the action it does, in this example "Executing command: hostname -d"

Another example here when I run the command on a good server and on the bad server.

Bad server:

[root@bad-server /]# DOMAIN=`vzctl exec 3333 'hostname -d'`
[root@bad-server /]# echo $DOMAIN
Executing command: hostname -d example.com

Good server:

[root@good-server ~]# DOMAIN=`vzctl exec 4444 'hostname -d'`
[root@good-server ~]# echo $DOMAIN
example.com

My knowledge is limited, but I have tried several things checking rsyslog and the grub.conf, but nothing seems out of the ordinary.

I have no clue why it's displaying the extra information.

Probably it's something simple / stupid, but I have been trying to solve this for hours now and I really have no clue...

So any help is really appreciated.

Added information: Both servers use: kernel.printk = 7 4 1 7 (I don't know if that's useful)


Solution

  • Well (thanks to Aaron for pointing me in the right direction) I finally found the little culprit which was causing all the issues I experienced with this script (which worked for every other server, so no need to change that obviously).

    The issues were caused by the VERBOSE leven set in vz.conf (located in /etc/vz/ directory). There is an option in there called "VERBOSE" and in my case it was set to 3.

    According to OpenVZ's website it does the following:

    Increments logging level up from the default. Can be used multiple times. 
    Default value is set to the value of VERBOSE parameter in the global
    configuration file vz.conf(5), or to 0 if not set by VERBOSE parameter.
    

    After I changed VERBOSE=3 to VERBOSE=0 my script worked fine once again (as it did for every other server). :-)

    So a big shoutout to Aaron for pointing me in the right direction. The answer is easy when you know where to look!



    Sorry to say, but I am kinda disappointed by ndim's reaction. This is the 2nd time he was very unhelpful and rude in his response after that. He clearly didn't read the issue I posted correctly. Oh well.