0

I'm trying to create a script to automatically compile apache. Sadly on my work I need to compile each an every apache I install.
So, I came up with this little code to run a command:

print("Source location %s" % source_location)
print("Configure command %s" % configure_command)
config = subprocess.Popen(configure_command, stdout=subprocess.PIPE, shell=True)
(output, err) = config.communicate()
config_status = config.wait()
print("Return configure status = %s" % config_status)

At the moment I'm stuck on the configure part.
Basically the configure line is like this:

/Volumes/nirvash/script/workarea/httpd-2.2.31/configure --prefix=/tmp/apache-2.2.31-instance1 --enable-mods-shared=all --enable-proxy --enable-proxy-connect --enable-proxy-ftp --enable-proxy-http --enable-deflate --enable-cache --enable-disk-cache --enable-mem-cache --enable-file-cache --with-included-apr --with-mpm=worker

The problem is that when the apache is compiling, it creates (mkdir) an "include" directory inside the httpd-2.2.31. But in this case the directory is created on the bin directory of my script.
So the directory is created were the script is running.

Is it possible to fix this? Is there any way to run the configure in the directory that is compiling?

1 Answer 1

1

You can use os.chdir to change the current directory of your script to be the same as the directory which contains the source code.

os.chdir(source_location)

Alternately, you could change configure_command to first change directories using cd prior to running configure.

configure_command = 'cd "%s" && %s' % (source_location, configure_command)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.