Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: system commands/shell and perl variables.
by choroba (Cardinal) on Jan 21, 2019 at 21:42 UTC | |
by NetWallah (Canon) on Jan 22, 2019 at 06:42 UTC | |
Re: system commands/shell and perl variables.
by haukex (Archbishop) on Jan 22, 2019 at 15:02 UTC | |
by knight.neo (Initiate) on Jan 22, 2019 at 17:34 UTC | |
by haukex (Archbishop) on Jan 22, 2019 at 18:00 UTC | |
by knight.neo (Initiate) on Jan 22, 2019 at 19:07 UTC | |
by haukex (Archbishop) on Jan 23, 2019 at 20:15 UTC | |
Re: system commands/shell and perl variables.
by NetWallah (Canon) on Jan 22, 2019 at 22:11 UTC | |
Re: system commands/shell and perl variables.
by karlgoethebier (Abbot) on Jan 22, 2019 at 09:59 UTC |
Back to
Seekers of Perl Wisdom