Got a peculiar problem which I don't know if it's a VPC for linux or my own stupidity on my perl scripting abilities.
I wrote a Perl wrapper to execute RedHatRepositoryManager.sh. This wrapper takes inputs from the Job, determines what Red Hat Repository this job should run against, and then executes the command line via the "exec" function in Perl.
The problem I am having is that the native RedHatRepositoryManager.nsh script (RedHatRepositoryManager.sh is just a wrapper that calls nsh) is stripping the first "/" slash from the path to the repository. So jobs that runs end up having the following error:
Info Oct 26, 2009 5:34:55 PM Started running the job 'Repository Update - RHEL-PRIMARY' on application server 'emda-nbp-uea21.corp.csa.ic.gov'(1)
Info Oct 26, 2009 5:34:56 PM Executing work item NSH Script Job:Repository Update - RHEL-PRIMARY; on application server: emda-nbp-uea21.corp.csa.ic.gov
Info Oct 26, 2009 5:34:57 PM Checking default java version.... 1.5.0_20
Info Oct 26, 2009 5:34:58 PM Loading the configuration file "/opt/bmc/bcas/patch/SupportFiles/RedHatRepositoryManager/configuration.properties"
Info Oct 26, 2009 5:34:58 PM Initializing ...
Info Oct 26, 2009 5:34:58 PM Directory /emda-nbp-uea21/opt/bmc/bcas/patch/rhel-repo does not exist or not a directory. Creating one....
Info Oct 26, 2009 5:34:58 PM Could not create /emda-nbp-uea21/opt/bmc/bcas/patch/rhel-repo. Can not proceed...
Info Oct 26, 2009 5:34:58 PM Exit Code 0
Info Oct 26, 2009 5:34:58 PM The job 'Repository Update - RHEL-PRIMARY' has succeeded
So I copied the whole NSH script (which is just a perl script) that is executed against this host, and I am running locally, and it still complains that "/emda-nbp-uea21/opt/bmc/bcas/patch/rhel-repo" doesnt exist. But because I am running as "root", it runs fine as it has the necessary privileges to create the directory (whereas via the job, it runs as bladmin and it doesn't).
Here's what I validated so far:
- The exact command that is executed via the "exec" function is indeed making to the exec command in the proper form (e.g. I echo it out in the script while having the exec command commented off, and the two slashes are there).
- I've tested if escaping any "forward" slash before executed by "exec" makes any difference. It doesnt.
- I've tested running the command interactively, and the same problem occurs. Again, I never noticed before as I was running it as "root" thus the erroneous directory creation was done without much alarm:
[root@emda-nbp-uea21 Work]# /opt/bmc/bcas/patch/SupportFiles/RedHatRepositoryManager/RedHatRepositoryManager.sh -command createUpdateRepo -channel rhel-x86_64-server-5 -yumRepo y -repoLocation //emda-nbp-uea21/opt/bmc/bcas/patch/rhel-repo
Checking default java version.... 1.5.0_20
Loading the configuration file "/opt/bmc/bcas/patch/SupportFiles/RedHatRepositoryManager/configuration.properties"
Directory /emda-nbp-uea21/opt/bmc/bcas/patch/rhel-repo does not exist or not a directory. Creating one....
"-yumRepo" or "-obsoleteYum" parameters are missing......considering values from "configuration.properties" file.
Create Update Repository Channel label - rhel-x86_64-server-5 Repository path - //emda-nbp-uea21/opt/bmc/bcas/patch/rhel-repo.
Previous cached credentials Found...
Checking the packages available for channel rhel-x86_64-server-5 for downloading...
Thanks for any input. You can run the below by doing:
./test.pl -r RHEL-PRIMARY -a UPDATE (note, RHEL-PRIMARY translates to //emda-nbp-uea21/opt/bmc/bcas/patch/rhel-repo).
$REPO_NAME = $opt_r ;
$ACTION = $opt_a ;
$HOST = $opt_f ;
$COMMAND = "NOTSET" ;
if ($ACTION =~ /YUMMIFY/)
$COMMAND = "yummifyRepo" ;
elsif ($ACTION =~ /UPDATE/)
$COMMAND = "createUpdateRepo -channel rhel-x86_64-server-5 -yumRepo y" ;
open REPOFILE, "<", $REPO_FILE ;
if ($_ =~ /$REPO_NAME/)
($junk, $repostring) = split(/=/, $_) ;
($REPO_LOC, $junk2) = split(/,/, $repostring) ;
$REPO_LOC =~ s/\//\\\//g ;
$EXECUTE = "$RHDL_PATH/RedHatRepositoryManager.sh -command $COMMAND -repoLocation $REPO_LOC" ;
#print "$EXECUTE\n" ;