I am trying to install some software tool onto my Ubuntu 16.04 partition. The install script kinda breaks here:

getInstalledLegacyPXIRMPackage() {
    part=`$RPM -q $kLegacyPXIRMBaseName`
    if [ $? -eq 0 ]; then
        echo $part
    echo ""

The error message I get is bash: -q: command not found.

This is part of an INSTALL file for a 32-bit version of labview 2012.

What is this error and what do I do to fix it? Thanks!

Edit: Okay sorry, technically, it does not break at the func definition. It breaks when it is called here:

if [ "$(getInstalledLegacyPXIRMPackage)" != "" ] && [ "$(getIncludedPXIPSPackage)" == "" ]; then
  • 3
    Think about what happens if the variable RPM is empty? (or if you tried to run a command like $foo arg otherarg with never having set foo)
    – ilkkachu
    Dec 11 '17 at 18:11
  • Checking your code with shellcheck is a great start.
    – PesaThe
    Dec 11 '17 at 18:34
  • Also, Ubuntu, being derived from Debian, uses apt for its package management rather than rpm or yum.
    – DopeGhoti
    Dec 11 '17 at 18:36
  • Hmm, I hope the code you're really trying to run has normal spaces instead of the ones in this code block (I'm not sure what they are)
    – ilkkachu
    Dec 11 '17 at 18:51

The error is due to the variable RPM being empty or undefined at the time of executing the getInstalledLegacyPXIRMPackage function.

If $RPM is empty or undefined, the line

part=`$RPM -q $kLegacyPXIRMBaseName`

will be interpreted as an assignment of the result of the command -q $kLegacyPXIRMBaseName.

Make sure that you assign the proper value to RPM (and to kLegacyPXIRMBaseName).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.