#!/usr/bin/perl -w
my $file = "/mypath/myenv.env";
open (FILE, ". $file ;script_init $0 $* ;set |") or
die ("Cannot Open $file ($!)");
while (<FILE>){
chomp;
print "$_\n";
}
Output:
sh: script_init: command not found
Problem:
I've break down the script to simulate this particular error, $file = is the environment file to be loaded which included the path of script_init and other variables.
script_init = global script function that is used for script initialization for other scripts to load environment variables.
Scenario:
if I'm running the script_init in a regular shell or called in a script(not perl) it's working. example usage of script is like this.
#!/bin/ksh
. /mypath/myenv.env
script_init "$0" "$*"
main script.. etc...
or in shell
$ script_init anotherscript parameter
but if i call it in perl, it doesnt recognized the script_init which resulted to command not found even it loaded the . $file (env)
. $file (env)
needed for the script.
my $file = "/mypath/myenv.env";
open FILE, qq{ksh -c ". $file ; script_init $0 $* ; set" |} or
die ("Cannot Open $file ($!)");
while (< FILE >){
chomp;
print "$_\\n";
}
Again many thanks!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.