perl - Installing cpanm in a bash script -


i'm writing script installs , configures nagios requirements. requires cpanm , perl modules.

it's using step/try/next function here: https://stackoverflow.com/a/5196220

step "downloading cpanm installer"  try `wget -q http://cpanmin.us -o $swrepo/cpanm.install` next  step "installing cpanm"   try echo '{ exec </dev/tty; cat $swrepo/cpanm.install | perl - app::cpanminus; }' | bash   # try bash -c "$(cat $swrepo/cpanm.install | perl - app::cpanminus)"   # try cat $swrepo/cpanm.install | perl - app::cpanminus next  step "installing perl module nagios config"   try `cpanm nagios::config` next 

my problems here are:

  1. whichever way attempt run install cpanminus, fails script, , won't install properly. can't seem make function outside of step/try/next functions (not want to.)

  2. the cpanm command fails too. if isolate , run part of script, still fails, "cpanm command not found." can run manually @ command line.

any pointers frustrated?

update

i pulled cpanm setup out separate file: step "installing cpanm" try sh conf_cpanm.sh next

which works, , i'll try , pull in @ later date, far functions. can stay.

however, doing same try cpanm nagios::config won't work. file looks this:

#!/bin/bash cpanm nagios::config 

...and if run calling sh conf_nagcpanm.sh works fine.

i think using backticks

try `cpanm nagios::config` 

is mistake. bash take expression in backticks, execute it, , substitute output of command expression. output of cpanm not going shell commands, not work. should be

try cpanm nagios::config 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -