Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a bash script where I need to run an init utility within a directory with a configuration file defined. I don't think it's possible to explicitly tell the utility to run the file as an argument, so what I need to do is go to the directory with the config file, and then run the command. I have some logic in place, but its not working -- the utility never runs. Is there any way I can tell the script to go to this directory, and then run the script?

cd /var/www/
eval "standardprofile"
share|improve this question
Could you be more clear? You could specify the config file in the bash script and just execute the bash instead. What does it need to pull from the config, etc. would help. And yes, you can run the file as an argument - the question is what pieces need to come from it. – nerdwaller Nov 21 '12 at 22:06

Use a subshell (sub-process?).

( cd /the/best/dir/in/the/universe; /path/to/util < /util/config.ini )


$ pwd

$ (cd /cygdrive/c/tmp/;  pwd)
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .