Hello there, how you guys doing? Hope well.
I'm trying to write a perl script which will receive command line arguments and pass it to system.
#!/usr/local/bin/perl
use strict;
use warnings;
# Check if program is being executead as root
if ("$>" ne "0") {
print "This program can't be executed as root\n";
exit 2
}
# Get running vm's
my @get_vm_list = (`xl list`);
sub show_vm_list {
print @get_vm_list;
}
my $vm_run = pop @ARGV ;
my %rec_args = ( vmlist => \&show_vm_list,
getdomid => \&get_dom_id,
);
my $arg = shift @ARGV;
if (defined $arg && exists $rec_args{$arg}) {
$rec_args{$arg}->();
}
OK
here is my function which I'm trying to get working
sub get_dom_id {
my $XENDOMID = "xl list| DOM_ID=`fgrep $vm_run` | awk '{print $
+2}'` && VNCPORT=`ps x \
| fgrep -m 1 "domid $DOM_ID" | awk '{print $1}'` && sockstat -4l | fgr
+ep $VNCPORT | awk '{print $6}'";
print `$DOMID`;
}
I have already tried set system environment using $ENV{'MYVAR'} without success
Any Directions will be appreciated, thanks in advance