Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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/testing-dev.example.co
eval "standardprofile"
share|improve this question
2  
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

1 Answer 1

Use a subshell (sub-process?).

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

e.g.

$ pwd
/home/jaroslav

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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