Say, I have a shell script like this:
function getDir
{
echo "DirName"
}
I want to use that function from a Perl script:
`source utils.sh`;
my $dir_name = `getDir`;
print $dir_name;
But this is not working. How I can get this done? Essentially I need to get the return value from a shell function to a Perl script.
You'll need to call that function in the same shell that sources utils.sh, so:
my $dir_name = `source utils.sh; getDir`;
chomp($dir_name);
print $dir_name, "\n";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With