I have a shell script where there are two subroutines written which take argument, massage that argument & then provide new value as an output.
This script is used by many other shell scripts. Now I have a Perl script where I want to call these shell subroutines with arguments. Below is my code:
#! /bin/sh
extract_data()
{
arg1 = $1
// massage data code
output=massaged data
return 0
}
Perl script:
my $output = `source /path/my_shell-script.sh; extract_data arg1`;
So here I want to assign value of output variable from shell subroutine to output variable of Perl script. But what I have found is it is available only if I echo that output variable in shell subroutine like below.
#! /bin/sh
extract_data()
{
arg1 = $1
// massage data code
output=massaged data
echo $output
}
I do not want to echo output variable as it is sensitive data & will be exposed in the logs of other shell scripts.
Please advise.