ubuntu - Bash script to run "pecl install oci8"
2014-04
I am trying to create shell script that will do the initial provisioning of a vagrant vm (running Ubuntu 12.04). Everything (installing php, apache, oracle instantclient, etc,) works fine, except for the last step - installing the php oci8 extension:
pecl install oci8
When I run this command manually (with sudo prefix) it works fine. But when the script runs this command it fails like this:
running: make
/bin/bash /tmp/pear/temp/pear-build-rootG74SsU/oci8-2.0.6/libtool --mode=compile cc -I. -I/tmp/pear/temp/oci8 -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootG74SsU/oci8-2.0.6/include -I/tmp/pear/temp/pear-build-rootG74SsU/oci8-2.0.6/main -I/tmp/pear/temp/oci8 -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/oci8/oci8.c -o oci8.lo
libtool: compile: cc -I. -I/tmp/pear/temp/oci8 -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootG74SsU/oci8-2.0.6/include -I/tmp/pear/temp/pear-build-rootG74SsU/oci8-2.0.6/main -I/tmp/pear/temp/oci8 -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/oci8/oci8.c -fPIC -DPIC -o .libs/oci8.o
In file included from /tmp/pear/temp/oci8/oci8.c:48:0:
/tmp/pear/temp/oci8/php_oci8_int.h:60:17: fatal error: oci.h: No such file or directory
compilation terminated.
make: *** [oci8.lo] Error 1
ERROR: `make' failed
The pecl
script asks for a path in the beginning of the installation, and this is where I think the issue is:
Please provide the path to the ORACLE_HOME directory. Use 'instantclient,/path/to/instant/client/lib' if you're compiling with Oracle Instant Client [autodetect] :
For the installation to proceed you either need to supply the ORACLE_HOME directory or press Enter. I have tried the following suggested elsewhere, but it does not work - the line break is missing in the output (compared to when running the pecl
command manually) so it does not properly emulate the Enter keystroke:
printf "\n" | pecl install oci8
Any suggestions on how I can get this to run properly?
My solution was to run the following command:
export C_INCLUDE_PATH=/usr/include/oracle/11.2/client
and restart:
pecl insatlla oci8
I did not really find a general purpose solution to this problem. What ended up working in my specific scenario (provisioning via Vagrant) was using a Puppet manifest for this specific provisioning step, which was easy since you just need to specify it in the Vagrant configuration after the Shell provisioner:
"pecl-install-oci8":
command => "pecl install oci8",
user => root,
timeout => 0,
tries => 5,
unless => "/usr/bin/php -m | grep -c oci8";
For some reason that I have yet to figure out, puppet installs oci8 without issue.
And when I'd done this I ported my whole script to a Puppet manifest, but that is off-topic.
I'm trying to create a scheduled task that runs a shell script recurrently, and I'm having some trouble getting it to work. I give it the following command to run every minute:
~/Desktop/foo/my_script
But it doesn't ever run. (This command runs the shell script through the terminal no problem.) Any ideas what I'm doing wrong? Thanks!
Note: Here's my shell script:
#!/bin/bash
sleep 15
date >> output.txt
{ time ./foo > /dev/null ; } 2>> output.txt
And here's the cron line:
* * * * * /home/joe/Desktop/foo/my_script # JOB_ID_3
The scheduler most likely doesn't know how to expand ~
try giving it an absolute path instead.
EDIT, after solution found:
Another idea I had was that maybe cron was ignoring the line due to all *'s, but I couldn't replicate this. I did find that it's man page is rather unhelpful, but that wikipedia's page on cron is somewhat useful. I was going to suggest using the line:
*/1 * * * * /home/joe/Desktop/foo/my_script # JOB_ID_3
as this would run at */1
(ie every minute that divides by 1) if it continued to fail.
I figured out the problem. Cron runs the tasks in the home directory, so that's where my output file is showing up. This is why I thought it wasn't running.