PDA

View Full Version : [ubuntu] [SOLVED] Script works but NOT in bash script file.



niiklas
November 14th, 2008, 03:50 PM
Hello!

this is my script file:


#!/bin/sh
#run testlink
php -f /path/to/file/index.php
#sync live folder.
sudo rsync -av /path/to/file/playlists /path/to-file/playlists


When i run:


php -f /path/to/file/index.php

in termninal it works but in the script i get following error:


root@server:/home/niklas# ./scriptname.sh
Warning: include_once(include/classes/database.class.php): failed to open stream: No such file or directory in /path/to/file/include/config.php on line 15

Warning: include_once(): Failed opening 'include/classes/database.class.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /path/to/file/include/config.php on line 15


Fatal error: Class 'Database' not found in /path/to/file/include/config.php on line 17

kpkeerthi
November 14th, 2008, 03:58 PM
Change Line#1 to


#! /bin/bash

and try again.

niiklas
November 14th, 2008, 04:00 PM
Change Line#1 to


#! /bin/bash

and try again.

i tried that but it gives the exact same error. :S

olejorgen
November 14th, 2008, 04:13 PM
Are you sure "php -f /path/to/file/index.php" works when you run it from eg. you home folder?

If "database.class.php" is in "/path/to/file/include/classes/database.class.php" it will only work if current directory is "/path/to/file/"

You could try to add "cd /path/to/file/" at the beginning of your script

niiklas
November 14th, 2008, 04:16 PM
it was something wrong with my php script that has never caused problems before now. SOLVED

Olejorgen, kpkeerthi. Thank you both for your time.