Article ID: 3987, created on Mar 5, 2008, last review on Jul 10, 2015

  • Applies to:
  • Odin Business Automation Standard 4.5


Sometimes it is necessary to perform a command in Container on event of Container creation or when an application template is installed into Container. Also, sometimes Provider wants to adjust some settings in a group of Containers at once.


You can run a script inside OBAS server to perform a command in a Virtuozzo Container registered in OBAS. Such script can be called either from command line, or set as 'Run Custom Script' action on an event, such as events 'Container has been created', 'Application template has been installed into Container'.

Here is example script which retrieves Plesk admin password from a Windows Plesk container. Script receives Container ID as first argument.


use strict;

map { delete( $ENV{ $_ } ) } keys %ENV;

use HSPC::Console;
use HSPC::MT::OM;
use HSPC::MT::VESrv;
use HSPC::MT::VESrv::Constants;

my $ve_id = $ARGV[0];

my $ve=HSPC::MT::OM->find_ve(id=>$ve_id);
die("Can't find VE #$ve_id") unless ($ve);
my $gate = HSPC::MT::VESrv->find_gate_obj(ve_obj => $ve, 
                                                       gate_id => SW_VESRV_GATE_VE);
die("Can't open gate") unless ($gate);

my ($cmd_err, $cmd_out);
my $ret_code = $gate->exec(
                 argv => [
                stderr => \$cmd_err,
                stdout => \$cmd_out,

if ($ret_code) {
        print "Error: $ret_code:$cmd_err:$cmd_out\n";
else {
        print "Result: $cmd_out\n";

For Linux Container we also can use /bin/sh as argv, and pass a command in stdin, which allows to perform several commands at once. Example (setting new Plesk admin password): `my $cmd = <


my ($err, $out);
                env     => {'LANG', 'C'},
                argv    => ['/bin/sh'],
                stdin   => \$cmd,
                stderr  => \$err,
                stdout  => \$out

Here is another example, a script that sets NETFILTER value of a container to FULL via command line:

ssh root\@@@ve.hw_name@ "vzctl set --save --netfilter full"

Search Words

custom script

400e18f6ede9f8be5575a475d2d6b0a6 caea8340e2d186a540518d08602aa065 624ca542e40215e6f1d39170d8e7ec75 70a5401e8b9354cd1d64d0346f2c4a3e

Email subscription for changes to this article
Save as PDF