Here's another explanation:
#!/bin/bash
# enable debug
set +xe
# this is an old school way to check for an empty variable
# modern shells can use [[ $foo == "" ]] to do this
if [ x"$Link_A" == "x" ] ; then
# a normal error message for when the variable is not set
echo "Link_A parameter not set, DOESNOT execute FUNCTION"
else # the variable has a value so we can use it...
# copy this file to the current directory
cp -f ~/cached-resources/www.github.com/file1/executables/JenkinsScripts/jenkins_feed.pl ./jenkins_feed.pl
# run the script in perl with arguments that include variable
# substitution and some fixed text
perl jenkins_feed.pl $JENKINS_HOME/feed_bts.ini $Link_A
fi
I also reformatted the script so the inner parts of the conditional are indented.
bonus questions from comments
- Is Link_A a file ?
Link-A is a variable. A variable could point to a file or directory, but it isn't clear what the variable would contain in this case. Examining the perl script would be necessary to answer this definitively.
- what does feed_bts.ini means do i need to create a file like this explicitly if not present?
I'd guess the perl script is expecting a file name as its first argument. The shell script provides this and it expects the feed_bts.ini file to be in the $JENKINS_HOME (another variable) directory.
- Do I need to keep the jenkins_feed.pl and feed_bts.ini in same directory to run the script?
The jenkins_feed.pl ends up in the same directory as the shell script because of the cp. It starts as ~/cached-resources/www.github.com/file1/executables/JenkinsScripts/jenkins_feed.pl. Note that ~ would the home directory of the user the script runs as.
- from which path is the perl script executing
This would probably be using whatever the stock perl installed with your distro is. Technically the shell will look through all of the directories in your $PATH until it finds it or runs out of directories.
perl script analysis