ADC PHP enabling shell script throws errors
Hi, guys.
I recently tried to enable PHP on my MacBook Pro.
I speak some bash, but no AppleScript.
On the Apple Developer Center they write you a little script to enable PHP, which failed repeatedly before numerous edits by me. I eventually massaged the script to work, but I want to understand *why* the script didn't work.
The code they give is as follows (and you can find it here: http://developer.apple.com/mac/articles/internet/phpeasyway.html):
set admin_email to (do shell script "defaults read AddressBookMe ExistingEmailAddress")
user_www=$HOME/Sites
filename=php-test
user_index=${user_www}/${filename}.php
user_db=${user_www}/${filename}-db.sqlite3
# NOTE: Having a writeable database in your home directory can be a security risk!
conf=`apachectl -V | awk -F= '/SERVER_CONFIG/ {print \$2}'| sed 's/"//g'`
conf_old=$conf.$$
conf_new=/tmp/php_conf.new
touch $user_db
chmod a+r $user_index
chmod a+w $user_db
chmod a+w $user_www
echo "Enabling PHP in $conf ..."
sed '/#LoadModule php5_module/s/#LoadModule/LoadModule/' $conf | sed
"s^[email protected]^\$admin_email^" > $conf_new
echo "(Re)Starting Apache ..."
osascript <<EOF
do shell script "/bin/mv -f $conf $conf_old; /bin/mv $conf_new $conf;
/usr/sbin/apachectl restart" with administrator privileges
EOF
Here are where this code throws errors for me:
First:
set admin_email to (do shell script "defaults read AddressBookMe ExistingEmailAddress")
I don't even recognize the shell syntax that this would work in. It's sort of csh like. Is this AppleScript?
Anyway, OS X bash chokes on this at the first '(' and I changed it to:
admin_email=`defaults read AddressBookMe ExistingEmailAddress`
which works just fine.
Second:
chmod a+r $user_index
I have no idea how his is supposed to work without 'touch $user_index'
I added:
touch $user_index
to the script.
Third:
conf=`apachectl -V | awk -F= '/SERVER_CONFIG/ {print \$2}'| sed 's/"//g'`
Okay, this actually *works*, but I don't know why it should. In my book, it should choke on the \$2, because the \ is invalid.
I've left it because it works and if it works it isn't wrong, but I would have written:
conf=`apachectl -V | awk -F= '/SERVER_CONFIG_FILE/ {print $2}' | sed 's/"//g'`
which I've tested and also works.
I'd like to know why Apple's first line works.
Fourth:
sed '/#LoadModule php5_module/s/#LoadModule/LoadModule/' $conf | sed "s^[email protected]^\$admin_email^" > $conf_new
The error here is that:
sed "s^[email protected]^\$admin_email^"
doesn't replace [email protected] with the contents of $admin_email.
I don't know what the and are supposed to do, but this just replaces the string '[email protected]' with the string '\$admin_email'
I replaced this with:
sed 's^[email protected]^'$admin_email'^'
This gives me a final script of:
#!/bin/sh
admin_email=`defaults read AddressBookMe ExistingEmailAddress`
user_www=$HOME/Sites
filename=php-test
user_index=${user_www}/${filename}.php
user_db=${user_www}/${filename}-db.sqlite3
conf=`apachectl -V | awk -F= '/SERVER_CONFIG/ {print $2}'| sed 's/"//g'`
conf_old=$conf.$$
conf_new=/tmp/php_conf.new
touch $user_index
touch $user_db
chmod a+r $user_index
chmod a+w $user_db
chmod a+w $user_www
echo "Enabling PHP in $conf ..."
sed '/#LoadModule php5_module/s/#LoadModule/LoadModule/' $conf | sed 's^[email protected]^'$admin_email'^' > $conf_new
echo "(Re)Starting Apache..."
osascript <<EOF
do shell script "/bin/mv -f $conf $conf_old; /bin/mv $conf_new $conf; /usr/sbin/apachectl restart" with administrator privileges
EOF
which works just fine.
But I'm still confused - why did ADC have a code snippet that could have never worked? Or am I missing something obvious?
- Nathan
Hey, RanjeetJones!
You're probably right - it's a lot of code to uncomment a line and change the administrator setting.
And the first time I set up PHP, I just found and edited the config file.
But the script had me so confounded I went back to troubleshoot it and got all wrapped up in why it ended up that way.
And this will help the next coder who wants to learn PHP and maybe doesn't speak bash.
- Nathan
Similar Messages
-
Script throwing error" Object required: 'API'
Hi All,
We need help in one issue. We have following script which is running fine when we ran it from script editor, but when use this as expression in import format is throwing error
Error: An error occurred importing the file.
Detail: Object required: 'API'
At line: 12
Script:
Function ME_to_LE(strField, strRecord)
ME_to_LE =API.SqlMgr.fMapItemLookup (749, "UD8", Left(strField,3))
End Function
We have created few other Scripts which are running fine and producing required result when we check them with MsgBox. But when we are using these scripts in import format it is saying: Object required: 'API'
IF I can not use API object in import script, how can I process multiple column with one script. We need to derive three-four column based on one input column and we don't want to write separate import script for each column. How and where we can write this script?
Are we missing any step? Any help will be highly appreciated. Looks I asked long question :)
Thanks,
Shivendra
Edited by: shiv2 on Sep 16, 2011 9:30 AM
Edited by: shiv2 on Sep 16, 2011 10:36 AMHi Robb,
"It looks like you and James are on the same project" That is correct.
OK. In requirment we have three-four column based on these column we need to derive few other column. We want to do spilitting and validation in Import itself. This is mainly a Validation requirment.
There is one column which may have 12,13,14,17 or any other number of character in it. first three will represent one dimension but exact value be a mapped result based on these three digits.
There are many validation based on the number on charaters and most importantly we don't want to process other column is validation get failed at any stage.
Do we have anything like Import Action? Probably we want to change that script. Or if we can write something like integration script. We need every column to be processed in one shot.
I don't think it is self explantry. Can we have your email please?
Thanks,
Shivendra
Edited by: shiv2 on Sep 16, 2011 8:52 PM -
Displaying std field in enable mode after throwing error msg
Hi experts,
I have a requirement where i need to check the value enterred in standard field (final grade) of infotype 0022 and need to throw error message, when the user click save button in PA30.
But the problem is, if i throw Error message, that field becomes disable and the user have to go back and come back for entering the correct value. So, my requirement is taht the field should still be in enable mode even after getting the error message.
pls tell me how to achive the same?Hi Shanti,
You don't need to display a message of type ERROR as this will lock the screen and will prevent the user from providing further input. You can use the following thing
MESSAGE i001 DISPLAY LIKE 'E'.
This will serve your purpose by displaying the error but will not lock the screen field and thus will not prevent the user from further input.
Have a look at the following link for more details : [ MESSAGE KEYWORD|http://help.sap.com/abapdocu_70/en/ABAPMESSAGE_OPTIONS.htm]
Hope this will help.
Thanks,
Samantak. -
Shell Script gives error when run through cron job.
Hi,
The following shell script runs without any problem when executed manulally.
USED=$(df -h /arch | tail -1 | awk '{print $5}' | cut -d '%' -f 1)
if [ ${USED} -gt 90 ]
then
find /arch/AUBUAT/ -type f -mtime +0 | xargs rm
find /arch/AUBMIG/ -type f -mtime +0 | xargs rm
fi
But the same gives below error when called from a cron job:
/backup/arch_test.sh: syntax error at line 1: `USED=$' unexpected
We are running following version:
bash-3.00$ uname -a
SunOS uaeaubdbdr01.aub.af 5.10 Generic_141444-09 sun4u sparc SUNW,SPARC-Enterprise
Kindly assist.
Thanks
Edited by: user13362786 on Apr 20, 2011 4:36 AMHi,
When I used #!/usr/bin/sh now even the manul execution of the script fails with the same err:
bash-3.00$ ./arch_test.sh
./arch_test.sh: syntax error at line 2: `USED=$' unexpected
And when I used #!/usr/bin/ksh the manual execution runs fine but again when the script is run from cronjob it now give dirrect err:
/backup/arch_test.sh[2]: df: not found
/backup/arch_test.sh[2]: tail: not found
/backup/arch_test.sh[2]: cut: not found
/backup/arch_test.sh[2]: awk: not found
/backup/arch_test.sh[3]: test: argument expected -
Dynamic xml from php script throws error: #1088 or #1085
Hi,
I'm importing xml formatted data from mysql via php script:
[code]
<?php
require_once('require.php');
$result = mysql_query("SELECT * FROM `songs`");
if($result)
header ("Content-Type: text/xml");
echo"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
echo"<songComments>\n";
while ($row = mysql_fetch_array($result))
echo"<testimonial>\n";
echo"<songComment>" . $row['title'] . "</songComment>\n";
echo"</testimonial>\n";
echo"</songComments>\n";
?>
[/code]
In one of my flash projects it's working just fine. But in the new one that I just sterted not anymore. And i have no idea why. I get this errors:
TypeError: Error #1085: The element type "songComments\n" must be terminated by the matching end-tag "</songComments\n>".
or:
TypeError: Error #1088: The markup in the document following the root element must be well-formed.
When I output that php into txt file and loaded in flash everything is fine, but not from php script directly.
Could it have something to do with that I'm testing that mysql locally on my computer using WAMP ? Previous project got all data from mysql from server.Ho could I trace what flash sees?
var url:URLLoader = new URLLoader();
url.addEventListener(Event.COMPLETE, xmlLoaded);
url.load(new URLRequest("getDataFromDB.php"));
private function xmlLoaded(event:Event):void {
myXML = new XML(event.target.data);
trace(myXML);
I got rid of that \n everywhere or move them around and it's still the same error 1088 or 1085 -
Network Utilization script throws error after re-executing
Hi everyone, I have a piece of code that finds the network util of a fileserver and if it is over 75% it stops executing the script. The script works the first time but after re-executing it, it throws an error. I've tried to null out all the variables I'm
using but it still won't work. Any help is appreciated! Thanks!
Code:
#Determines NIC utilization
$interfacebw = $null
$intbwbytes =$null
$currentbytespersec = $null
$linkutil = $null
Write-Host "Determining File Server Network Utilization.."
$interfacebw = Get-WmiObject -class Win32_PerfFormattedData_Tcpip_NetworkInterface -ComputerName tsvc2552101x001 | where {$_.Name -eq "Broadcom NetXtreme Gigabit Ethernet"} |select CurrentBandwidth
$intbwbytes = $interfacebw.currentbandwidth /8
$currentbytespersec = Get-WmiObject -class Win32_PerfFormattedData_Tcpip_NetworkInterface -ComputerName tsvc2552101x001 | where {$_.Name -eq "Broadcom NetXtreme Gigabit Ethernet"} |select BytesTotalPersec
[int]$currentbytespersec = $currentbytespersec.bytestotalpersec
if($currentbytespersec -le 0){
[int]$linkutil = 0
}else{
[int]$linkutil = ($currentbytespersec / $intbwbytes) * 100
#if NIC util is over 75 then it closes program
if($linkutil -gt 75){
$wshell.Popup("Network utilization over 75%, please try again later.",0,"Error",0x1) | Out-Null
$formSoftwareInstaller.Close()
return
Error:
Cannot convert value "@{BytesTotalPersec=3560}" to type "System.Int32". Error: "Cannot convert the "@{BytesTotalPersec=3560}" value of type "Selected.System.Management.ManagementObject" to type "System.Int32"."
At C:\Users\cody-horton\Desktop\Software Installer.ps1:406 char:9
+ $currentbytespersec = Get-WmiObject -class Win32_PerfFormattedData_Tcpip ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : MetadataError: (:) [], ArgumentTransformationMetadataException
+ FullyQualifiedErrorId : RuntimeExceptionThis is all you need to do. You are way over coding this.
Write-Host "Determining File Server Network Utilization.."
$perfdata=Get-WmiObject -class Win32_PerfFormattedData_Tcpip_NetworkInterface -ComputerName tsvc2552101x001 -Filter 'Name="Broadcom NetXtreme Gigabit Ethernet"'
$intbwbytes=$perfdata.currentbandwidth/8
$currentbytespersec=$perfdata.BytesTotalPersec
#if NIC util is over 75 then it closes program
if(($currentbytespersec / $intbwbytes) -gt .75){
$wshell.Popup("Network utilization over 75%, please try again later.",0,"Error",0x1) | Out-Null
$formSoftwareInstaller.Close()
return
¯\_(ツ)_/¯ -
Services, shell scripts and errors
Unix question here:
I am playing around with the new services feature of SL. Great stuff. Generally I am writing little one line scripts to do minor operations (like touch, for example). However, when there is an error in the script, the service craps out with an error dialog. I'd like to ignore the error & continue on. I've tried redirecting stderr to /dev/null, but it doesn't seem to work. Here is an example of a script that will fail the second time it is run over a set of files:
for i in *; do xattr -d com.apple.quarantine "$i"; done
Does anyone know of a way to get the service system to ignore any errors that the script may encounter?the standard unix way works for me. I'm not sure what problems you guys are having.
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #ADD8E6;
overflow: auto;"
title="this text can be pasted into the Script Editor">
for f in "$@"
do
xattr -d com.apple.quarantine "$f" >/dev/null 2>&1 &
done</pre> -
How to Compile the PL/SQL Package/ Procedure using shell script
Hi,
I tried to Compiled the shell script but I am facing some error.
Can any one help me how to compile the PL/SQL shell script without error. Awaiting for your valuable reply.
Thanks,
Arun Prakashuser8726849 wrote:
PL/SQL shell script without errorWhat's a PL/SQL shell script?
Can you please post exactly what you are trying to do (As in the actual code that you are executing and its output)? Also please post it in \ tags (See FAQ). -
Error with dbms_scheduler and shell script execution
Hi,guys.
I have an issue with a dbms_scheduler and a shell script execution. So, the shell script as it self works fine, when i'm executing ./test.sh all process is running, but when i'm executing the script from dbms_scheduler it just simply doesn't work. Actually it works, but some of executable information in sh doesn't work, seems it just jump over of the part of the script. Sendmail part is running, maybe there is problem with rman script as it self?
DB version: 10g
And my scripts:
Shell scripts (permisons 755):
#!/bin/ksh
export PATH=/home/oracle/product/asm_home/bin:/home/oracle/product/db_home/bin:/usr/bin:/etc:/usr/sbin:/usr/ucb:/home/oracle/bin:/usr/bin/X11:/sbin:.
export ORACLE_BASE=/home/oracle/product
export ORACLE_SID=zabbix
export ORACLE_HOME=/home/oracle/product/db_home
${ORACLE_HOME}/bin/rman<<EOF
connect target /
run {backup recovery area delete all input;}
EOF
{ echo "From:[email protected]"
echo "To: [email protected]"
echo "Subject: Recovery area"
echo 'Content-Type: text/html'
echo
echo '<html><body><table border="1" cellspacing="1">'
echo '<tr><td><b>Process</b></td><td><b>Statuss</b></td></tr>'
echo "<tr><td>RMAN</td><td><b>Works</b></td></tr>"
echo "</table></body></html>"
} | sendmail -tIn the first part i'm exporting all of the important stuff for oracle, then I call RMAN with specific atributes. And then there is just simply sendmail functionality inside script to represent if script works (for now).
And below pl/sql script:
begin
DBMS_SCHEDULER.CREATE_JOB
job_name => 'FLASH_RECOVERY',
job_type => 'EXECUTABLE',
job_action => '/home/oracle/backup/test.sh',
start_date => sysdate,
job_class => 'DEFAULT_JOB_CLASS',
enabled => TRUE,
auto_drop => FALSE,
comments => 'FLASH RECOVERY USAGE AREA backup and delete'
END;
/And this job execution:
begin
DBMS_SCHEDULER.run_job (job_name =>'FLASH_RECOVERY',use_current_session => TRUE);
end;What can be wrong? For me, I think it's something with permisions.
I hope you got my idea and could help me.
Tom
Edited by: safazaurs on 2013.18.2 22:16There is no error, i just receive all the time e-mail, seems it jumps over rman. I tried almost everything and still couldn't get result as i want. And, if i'm running script from command line - it works. Rman calls, and starts to recover archivelogs.
-
Error Using dbms_scheduler to call a shell script
Hi,
I have been assigned a job of sending emails through unix utility(Mailx), based on certain activity in database.
Email needs to be sent on insert/update of a column in one of the database tables.
I am trying to use the block below to call the unix script responsible to send mails:
begin
dbms_scheduler.create_job
job_name => 'TPP_SEND_EMAIL_JOB',
job_type => 'EXECUTABLE',
job_action => '/opt/ENV/code/BIL/users/usrbil01/Hemz/sndmailscrpt.ksh',
repeat_interval => 'FREQ=MINUTELY; INTERVAL=30',
enabled => true,
comments => 'Send Email on ISU update'
end;
sndmailscrpt.ksh: Script to send email is embedded within the shell script
I am getting the below error when i try to run the job using 'exec dbms_scheduler.run_job('TPP_SEND_EMAIL_JOB');'
Error:
ORA-27370: job slave failed to launch a job of type EXECUTABLE
ORA-27300: OS system dependent operation:accessing extjob wrapper failed with status: 2
ORA-27301: OS failure message: No such file or directory
ORA-27302: failure occurred at: sjsec 3
ORA-06512: at "SYS.DBMS_ISCHED", line 150
ORA-06512: at "SYS.DBMS_SCHEDULER", line 441
ORA-06512: at line 1
I am not aware of any db related permissions that needs to be given, is this related to that or is there somethin i need to do for execution to be successfull
Request you to let me know the exact solution and also the steps i need to take in order to ensure successfull execution of this script.
Please also let me know if there is any other way wherein i can call a unix script from a database trigger on run time(i.e, whenever insert/update on a particular column in database)
Regards,
HemanthHi All,
Thank you for your inputs.
I am now pressed to explore the option of utl_mail as this dircetly sends mail from database. This is suggested as an option for my delivery now.
I am able to install utl_mail and send a mail using the block below:
begin
utl_mail.send(
sender => '[email protected]',
recipients => '[email protected]',
subject => 'Testing utl_mail',
message => 'The receipt of this email is checking on working of UTL_MAIL '
exception
when others then
dbms_output.put_line('error: '||sqlerrm);
end;
The block gets executed successfully, but i have not received a mail yet, is there a table or oracle log from where i can trace the delivery status for the mai, or if the mail is successfully sent too?
I have heard from users in this forum for support of mime type "HTML", Should i pass the whole html body in the *'message'* input parameter here or can i pass a html template name with path present else where?
Please do assist me in this regard.
Regards,
Hemanth -
Dbms_scheduler error when running shell script
I have 2 shell scripts.
ftp_file_from_apps.sh copies a file from one server to antoher. It receives an input which is the name of the file to be copied.
scp_file_to_dbs.sh does a secure copy. Copying the file fo anther directory on the same server.
ftp_file_from_apps.sh
~~~~~~~~~~~~~~~~~
#!/bin/bash
sftp applprod@<host.domain>:/<source_directory>/$1
/<destination_directory>/$2
scp_file_to_dbs.sh
~~~~~~~~~~~~~
scp -r /<source_directory>/$1 <host.domain>:/<destination_directory>/$1
Both of these scripts works 100% when i run them from os level:
ftp_file_from_apps.sh xxx.out xxx.pdf
scp_file_to_dbs.sh xxx.pdf
the problem is when i run them with dbms_scheduler:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
v_file_name and v_file_name_pdf is varchar2(20) with values assigned.
begin
dbms_scheduler.create_job(
job_name=>'FTP_FILE_FROM_APPS',
job_type=>'executable',
job_action=>'/<directory_of_script>/ftp_file_from_apps.sh
v_file_name v_file_name_pdf',
enabled=>TRUE
end;
begin
dbms_scheduler.create_job(
job_name=>'SCP_FILE_TO_DBS',
job_type=>'executable',
job_action=>'/<directory_of_script>/scp_file_to_dbs.sh
v_file_name_pdf',
enabled=>TRUE
end;
ftp_file_from_apps.sh error:
ORA-27369: job of type EXECUTABLE failed with exit code: No such file or directory
scp_file_to_dbs.sh error:
ORA-27369: job of type EXECUTABLE failed with exit code: No such file or directory
I tripple checked my <directory_of_script>.
Please help.
Regards
JohnHi,
What Paul means is that you should not be using
job_action=>
'/<directory_of_script>/scp_file_to_dbs.sh v_file_name_pdf',
Instead job_action should be the name of the shell script only. So you should have
job_action=>
'/<directory_of_script>/scp_file_to_dbs.sh',
number_of_arguments=>1
enabled=>false
And then make a call to dbms_scheduler.set_job_argument_value (for each argument) and finally a call to dbms_scheduler.enable.
Hope this helps,
Ravi. -
Execve: Exec format error to execute shell script
I made job to execute a shell script.
exec dbms_scheduler.create_job (
job_name => 'run_sh',
job_type=>'EXECUTABLE',
job_action=> '/fsoracle/app/oracle/inst2/if_cft/send_file_susin.sh',
start_date=>sysdate + 1/5760,
enabled => TRUE
send_file_susin.sh
#!/bin/ksh
set -v
. /fsutil/ndm/axway/profile
/fsutil/ndm/axway/Synchrony/Transfer_CFT/bin/CFTUTIL << EOJ
CONFIG TYPE=COM,MEDIACOM=TCPIP,FNAME=$CFTTCP
SEND PART=ZADA,IDF=1363X1364,
FNAME='/fsoracle/app/oracle/product/rdbms/log/KFG.DD.SHRCOM.HRD.A03',
NFNAME=KFG.DD.SHRCOM.HRD.A03,
FLRECL=25,NLRECL=25
SWAITCAT SELECT='IDTU=="%_CAT_IDTU%"'
EOJ
This script is well executed in terminal mode, but it threwed error, [ORA-27369: job of type EXECUTABLE failed with exit code: Unknown error STANDARD_ERROR="execve: Exec format error"] when I executed the shell script, send_file_susin.sh.
I changed owners and chmods of some specific files, and t.sh was well executed.
t.sh
#!bin/ksh
/usr/bin/mkdir /tmp/test
I don't know what's wrong with the script, send_file_susin.sh.
Does any know about this? Please, tell me the solution.
Thanks in advance,
Jinbae Kim.Hi,
Posting this in case anyone else find it.
The key error here is "execve: Exec format error" .
The following things should be checked
- that the shell script is a text file has UNIX line terminators
- that the shell script is set to be executable by the user that the job runs as
- that the shell script begins with a hashbang line - e.g. #!/bin/sh (I suspect this is the problem)
For running external jobs on 10gR2 or below, refer to this post Guide to External Jobs on 10g with dbms_scheduler e.g. scripts,batch files
For running external jobs on 11g and up, please use a credential.
Hope this helps,
Ravi. -
Shell Script: Timeout and return error if Sqlplus hangs
Shell Script: Timeout and return error if Sqlplus hangs
Dear all,
This morning, our production database hung with lots of ORA-600 and 7445. The issue has been escalated to Oracle Tech support but my monitoring script which tries to make a connection every 5 mins to the database to see if its up, did not alert me. The reason is that, it connected to the database and hung, never came out to report an error and so I never got alerted until a user called me.
Can any one tell me how I can exit from the sqlplus block if I dont get a response in x seconds? This sqlplus block is being called with in a shell script.
Any help is highly apprciated.I don't know of anything built into any shell scripting language that would do this, no. I'm not a Perl programmer, but I have a vague recollection that Perl may have something useful here.
From the "separate thread" part of my comment, though, you could certainly spawn a separate thread (thread 2), have thread 2 wait a period of time, then look for a message from thread 1 and throw an error if the message hadn't been sent. I don't know that I'd be for writing multi-threaded shell scripts, though. The heartbeat also gives you a layer of redundancy so that something is monitoring the monitor in case that process stops working.
Justin -
Error in calling SQL plus program with parameter from Shell script
This is my Shell script. I am trying to call in the SQL plus program with the parameter and the shell script is registered as a concurrent program.
PARAMETERS=`echo $1 |tr -d '\"'`
DB_USER_ID=`echo $PARAMETERS|cut -d" " -f3|cut -d"=" -f2`
CONN_STRING=$DB_USER_ID
REQ_DATE=`echo $PARAMETERS|cut -d" " -f9|cut -d"=" -f2`
timestamp=`date +%m-%d-%y-%H:%M:%S-%Z`
timestam=`date +%y-%m-%d`
sqlplus -s $CONN_STRING @ar_statement.sql $REQ_DATE
chmod 755 statement.sh
. statement.sh
My Sql plus program is like this.
set pagesize 0
set heading off
set feedback off
spool $GEC_TOP/log/ge_ar_statement.sh
select output_file_name
from fnd_concurrent_requests
where trunc(actual_completion_date) = '&2';
spool off;
exit;
When i run the concurrent program, i am getting the following error:
ar_statement: line 14: REQ_DATE: command not found
Enter value for 2:
User requested Interrupt or EOF detected.
ar_statement.sh: line 1: Enter: command not found
ar_statement.sh: line 2: User: command not found
ar_statement
Program exited with status 127
I am not strong at Unix Porgamming and i would request someone who can
help me out as soon as possible.
I need this solution quickly and thank everyone in advance.
Thanks.Can you put your coding between code statements, like shown in the FAQ. It will be easier to read.
Looking at your script, my first guess is that crontab will not find your sqlplus since your script does not have $HOME/bin in the $PATH. From what I understand, running .profile in your script will not work either because variables are exported to sub-shells, not to the shell above. You can call your script with a dot like . ./script which means that the script will run like it was typed at the command prompt. But it will be less confusing to define appropriate variables in the script. eg.
ORACLE_SID=my_instance_name
ORACLE_HOME=/my_path_to_oracle_home_directory
LD_LIBRARY_PATH=$ORACLE_HOME/lib
PATH=$ORACLE_HOME/bin:$PATH
I remember some slightly different way of coding to handle the sqlplus return codes.
For instance:
sqlplus -s /nolog > /dev/null <<-EOF
connect system/manager
@ssm.sql
whenever oserror exit failure
whenever sqlerror exit failure
EOF
sql_err=$?
if [ $sql_err -ne 0 ]; then
echo "FAILURE"
else
echo "SUCCESS"
fiThe - in -EOF supresses tab's
Using connect will prevent ps from showing your login credentials
In some versions of bash the ending EOF needs to be at the beginning of the line to work.
Edited by: waldorfm on Jul 14, 2010 7:05 PM
complaining about putting code between code delimiters and forgot myself ;-)
Edited by: waldorfm on Jul 14, 2010 7:08 PM
Btw, if you "source" a script running it like . .script, than an exit in that script will log you out. -
Error while trying to execute a unix shell script from java program
Hi
I have written a program to execute a unix shell script in a remote machine. I am using J2ssh libraries to estabilish the session connection with the remote box.The program is successfully able to connect and authenticate with the box.
The runtime .exec() is been implemented to execute the shell script.I have given below the code snippet.
try {
File file_location = new File("/usr/bin/");
String file_location1 = "/opt/app/Hyperion/scripts/daily";
String a_mib_name = "test.sh";
String cmd[] = new String[] {"/usr/bin/bash", file_location1, a_mib_name};
Runtime rtime = Runtime.getRuntime();
Process p = rtime.exec(cmd, null, file_location);
System.out.println( "Connected to the server1" );
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = br.readLine();
while(line !=null)
System.out.println(line);
line = br.readLine();
br.close();
p.getErrorStream ().close ();
p.getOutputStream().close();
int retVal = p.waitFor();
System.out.println("wait " + retVal);
//session.executeCommand("ls");
catch (IOException ex) {
I get an error message
Connected to the server
java.io.IOException: Cannot run program "/usr/bin/bash" (in directory "\usr\bin"
): CreateProcess error=3, The system cannot find the path specified
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at SftpConnect.main(SftpConnect.java:143)
Caused by: java.io.IOException: CreateProcess error=3, The system cannot find th
e path specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
I am sure of the file path where the bash.sh and test.sh are located.
Am i missing something? Any help would be greatly appreciated.
Thanks
SenthilHi, I am using a simple program to connect to a RMI server and execute shell script. I use the Runtime.exec aommand to do the same.
The script is sh /tmp/pub/alka/test.sh /tmp/pub/alka/abc/xyz/ul ul
The script when run from the server, gives no errors. But when ran using rthe above method in java, gives errors as follows,
Mycode:
String command = "/bin/sh /tmp/pub/alka/test.sh /tmp/pub/alka/abc/xyz/ul ul";
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec(command);
int exitVal = proc.exitValue();
System.out.println("Process exitValue: " + exitVal);
java.io.IOException: CreateProcess: /bin/sh /tmp/pub/alka/test.sh /tmp/pub/alka/abc/xyz/ul ul error=3
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at DecryptTest.main(DecryptTest.java:18)
Can anyone please help
Maybe you are looking for
-
I put the numbers into my computers Network DNS area but the problem is when i type in my Routers address to see the system settings it redrects me to a 2wire search results page. So i can't log into my Routers System settings.
-
Iphone 4s will not mount on MacBook Pro (Via USB)
My iphone (6.1.3) won't connect to computer (Macbook pro (10.7.5). I rarely do this, so perhaps have inadvertantly turned off an important setting? But typically iphone is accessible from desktop, itunes and iphoto. Not visible anywhere currently. I
-
I have a hotmail email account and each time I click on a pdf attachment, Firefox asks me "What should Firefox do with this file?" I click "Open with - Adobe Reader (default)" then I check-mark "DO THIS AUTOMATICALLY FOR FILES LIKE THIS FROM NOW ON."
-
Is there a way to leave Windows 7 OS and install Windows 8 additionaly
Is there a way to leave Windows 7 OS and install Windows 8 additionaly with Bootcamp 5, means to have a triple boot option or dual boot option where the windows partition can choose to start windows 7 or windows 8 ?
-
Can you import local tables into Oracle to query in Discoverer?
long time lurker, first time poster... I've got a local list in excel of over 100k records. I want to bounce this list off our network's data in Oracle to add a few fields to my file. Is there a way to import the local list into Oracle (like I might