I need to run a PL/SQL Query from a distant oracle server in order to create spool files and send it to my own server, using a php script.
I firstly created a SH script called myscript.sh
let's say that my PHP script is like :
Note that the sql file myquery.sql does contain spools that are supposed to send files to my own server...
When i run the script from the command line, it works. I use an normal user (not root) to make it run When i run it from the php page, it doesn't work. Apache use www-data to run it, so i made sure to include the www-data group to the script. Note that i tried running
and that it works like a charm! i also tried to run another sh script without sqlplus command, and it also work.
I'm suspecting a permission problem with the sqlplus command, because the only difference between both methods to run the script is the user running it. But i don't know how to change user permissions to a command, or a possible escape to make it work. I'm out of ideas i tried several things such as exec(); or system(); instead of shell_exec(); and changing chown and chmod to both sql / sh files
i don't think the relative path is the problem, because if i run the php script with shell_exec('sh /var/www/directory/script.sh');
with script.sh being :
the echo command works, it will display "This script is working"
but the sql query does not run...it clearly shows that the php is not the problem, and i believe the problem is in the permission apache server user has to use sqlplus unix command.
I did not found enough information on the internet about this command (in oracle doc it really is looking for a needle in a haystack)...
Absolute path calls and getting all the Oracle environment variables, PATH, LD_LIBRARY_PATH set right for sql*plus in the wrapper. Interactively, it inherits all yours.
"var/path/to/whatever" means "start looking at the current directory", which may be the directory the PHP script is in.
"/var/path/to/whatever" means "Start looking in the root directory", making the current folder not matter.
My mistake is in the first post where i posted var/www/mydirectory/myscript.sh instead of /var/www/mydirectory/myscript.sh. But basically, both ways would lead in the same directory as var is placed in the root...and anyway, as i said before, the bash script call is working just fine (the echo command works and prompt the text i want) its really just the sqlplus command not working.
Quote:
Absolute path calls and getting all the Oracle environment variables, PATH, LD_LIBRARY_PATH set right for sql*plus in the wrapper. Interactively, it inherits all yours
I am not sure i have understood what you told me, sorry ;
1) If you are telling me i need the absolute path, i think /var/www/mydirectory/mysqlquery.sql is absolute path... right ?
2) Is there any special code to include to get the oracle environment variables ?
If you don't do so yourself, chances are your /etc/profile or your own ~/.profile or equivalent does so for you. Check the contents of those to see what they do, or just load /etc/profile itself like I suggested above.
Hi all,
i face an error related to my server ""it's running server"" when i use sqlplus command
$ sqlplus
bash: sqlplus: command not found
the data base is up and running i just need to access the sqlplus to import the dump file as a daily backup.
i already check the directory... (4 Replies)
i am using bash shell
Whenever i declare an array, and then using sqlplus, i am getting sqlplus error and return code 127.
IFS=","
declare -a Arr=($Variable1);
SQLPLUS=sqlplus -s "${DBUSER}"/"${DBPASS}"@"${DBASE}
echo "set head off ; " > ${SQLCMD}
echo "set PAGESIZE 0 ;" >> ${SQLCMD}... (6 Replies)
Hi ,
i am new to unix i need a small clarification regarding this
sqlplus -s $USER_NAME/$PASSWD@$ORA_SID<< EOF >> SQL_CONN_LOG.log
In the above command what is the meaning of <<EOF>>
Thanks,
krishna. (2 Replies)
Hey guys i've recently been getting into php programming and i became thinking was it possible to create a php script that would allow you to run a terminal from the browser page?
All i've pretty much got so far is:
$var = $_GET;
$output = php shell_exec($var);
echo $output;
... (4 Replies)
I installed Oracle 10.2.1.0 in Ubuntu 10.10..my installation was well,i could even open isqlplus( http://ubuntu.ubuntu-domain:5560/isqlplus/workspace.uix ) and execute some queries..But,back in terminal when i try to login to sqlplus i am getting error (20 Replies)
Hi, I've been working on a PHP script which is "supposed" to find an individuals weather based on their geolocation. This script uses "shell_exec".
I have checked my syntax and it is correct, but there is still something missing; for when I call on the script using:
<form action='/weather.php'... (15 Replies)
HI,
Does anybody know if its possible to execute a command through exec,
shell exec, system and if the program doesn't terminate in N seconds
returns control to PHP ?
reg,
research3
---------- Post updated 10-16-09 at 12:20 AM ---------- Previous update was 10-15-09 at 11:03 PM... (1 Reply)
hi,
i need bash shell script run on the crontab(Unix tru64).
i have write my shell. it's using sqlplus command and connect to oracle db.
execute cron job when i have error messege: "sqlplus: command not found"
have you any suggestion? (4 Replies)
Can someone tell me how to execute sqlplus command.
I`m Executing:
sqlplus user/pasw @/report/output/new/PlatformOut_Cdrs.sql
the error is:
SQL*Plus: Release 9.2.0.5.0 - Production on Wed Aug 9 15:37:44 2006
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
ERROR:... (3 Replies)
I have a ksh script that connects to sqlplus and dumps the query results into a file. The script works file when I run it from the command line, however, when I call it from PHP using system(), exec(), or shell_exec() commands, the script doesn't seem to run the query. It will create the text file... (7 Replies)