I have a file abc.ini and declared many variables in that file, one of the variable(DBname) value I am trying to read in my perl script but getting error.
File abc.ini content
# database name
DBname =UATBOX
my $ex_stat;
my $cmd_output;
$ex_stat = "\Qawk '/^DBname/{print substr(\$2,2)}' abc.ini\E";
$cmd_output = `$ex_stat`;
if ($cmd_output) {
print "ERROR\n";
}
print "CMD OUT: $cmd_output\n";
Error:
sh: awk '/^DBname/{print substr($2,2)}' abc.ini: No such file or directory
CMD OUT:
When I execute the command listed in the script output i.e. awk '/^DBname/{print substr($2,2)}' abc.ini, it executes fine and gives the desired output but in the script it gives error.
I would like to know where is the error.