Linux – execvp: No such file or directory

bashexeclinuxscript

I wrote a script ~/_bin/bcg to call another script that uses gimp to re-size a random image from a directory and then write it back out to another file. My (toplevel) script then uses hsetroot to set the X background to this image.

The only problems is that as soon as I call the other guy's script with exec !/_bin/aura, my script stops.

  1. Is there a way to call programs and scripts without exec?
  2. Is there a way to prevent exec from guillotine-ing my script?

If I run things without exec I get:

execvp: No such file or directory

I assume this means that bash implicitly uses some program execvp to parse each line and that program cannot find (or will not execute) ~/_bin/aura.

I can enter each line at the terminal and get what I want. I just can't put it all in a script, but that's what I want.

What can I do?

#!/bin/bash
if [ -f ~/.bcg.bmp ]
then
        rm ~/.bcg.bmp
fi
~/_bin/aura "~/_wall";
hsetroot -center ~/.bcg.bmp

Best Answer

Normally when you invoke a command in a bash script, the shell waits until the command completes and then runs the next command. When you use exec, you're telling the shell to replace itself with the command it is about to run, i.e. there is no shell once the command starts. So when the command finishes, it is as if the original script finished as well. You must run your command without exec if you want the script to continue running after the command finishes.

execvp: No such file or directory doesn't look like a bash error message. It is probably coming from the aura script, which is trying to run something that can't be found in your search path.

Related Question