[Nottingham-pm] [Fwd: Compiling Software In A Perl Script]

Michael Erskine msemtd at yahoo.co.uk
Mon Mar 13 00:38:45 PST 2006


On Sunday 12 March 2006 22:36, Robert Postill wrote:
> Hi,
> I'm developing an installer for a PHP-based app at work after getting
> sick and tired of building the thing by hand.  What I want is to collate
> the output from the compilation of Apache, PHP and MySQL into a single
> point, check that it's all OK and then save the output for later support
> perusal.  All of these apps are standard configure && make && make
> install jobs.  I need to make sure they have the right flags set (e.g.
> mbstring and LDAP support) and I also need to make sure they all land in
> one place (so uninstallation is a matter of rm -rf <install_dir>).  Now
> in classic Perl noob mode I'm thinking of using the system(command) to
> get my operations run.  Then redirecting the output to a file so I can
> check the actions succeeded.  So my questions are:
> 1. This is portable to AIX and the more niche unices right?

Yes, as long as the underlying commands are present and correct. Test, test, 
test... then test some more!

> 2. Is there a more efficient way of collecting the output rather than
> directing the stderr and stdout to a file?

You don't need to be efficient - Perl will do that for you! If it doesn't then 
it's no the right tool for the job. You could use backticks to collect the 
output directly but it won't separate stderr and stdout. See "perldoc -q 
stderr". I'd use system() to run the commands but use the shell to redirect 
stderr and stdout into separate files (if you want them separate). Then if 
they need processing in any way you can read them back in with File::Slurp or 
similar.

> 3.  Does this sound like high order lunacy to anyone for some reason?

No, it gives you the repeatability you want and it gives you better 
portability than a shell script. Let us know if you get stuck in any way.

Regards,
Michael Erskine.

-- 
You are here:   
		***
		***
	     *********
	      *******
	       *****
		***
		 *

		 But you're not all there.

		
___________________________________________________________ 
Yahoo! Photos – NEW, now offering a quality print service from just 8p a photo http://uk.photos.yahoo.com


More information about the Nottingham-pm mailing list