Sponsored Content
Top Forums Shell Programming and Scripting Script (with sql queries) not working using cron Post 302716735 by spacebar on Tuesday 16th of October 2012 11:23:19 PM
Old 10-17-2012
You shouldn't have to add all the 'export' items to your shell script if you can run sqlplus from the command line.
You should be able to just put the following lines at the top of your shell script:

Code:
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi


Or run your cronjob like the following so that the script is aware of the user environment variables:
Code:
## minute,  hour   , day of the month, month of the year,  day of the week script
## (0-59)  (0-23)          (1-31)            (1-12)         (0-6 0-Sunday)
##--------------------------------------------------------------------------------------------------
00 08 * * 2 . ~/.bashrc; /path/to/script/script.sh


And per the error(ORA-12545: Connect failed because target host or object does not exist) you are getting, check your tnsnames.ora file and look at this link:
ORA-12545: Connect failed because target host ...
This User Gave Thanks to spacebar For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

SQL queries in background?

I have to query a DB2 database, and sometimes they take a long time to produce results. Can I run these queries in the background, and if so, where will the results appear? (1 Reply)
Discussion started by: jpprial
1 Replies

2. UNIX for Dummies Questions & Answers

Sh Shell Script executing remote SQL queries

Hi there folks, I am trying to execute remote sql queries on an Oracle server. I would like to save the result of the executed sql queries on a text file, and send that text file as an attachment to an email address. Could anyone give me an idea on how the above could be achieved? Any help... (2 Replies)
Discussion started by: Javed
2 Replies

3. UNIX for Dummies Questions & Answers

shell script for sql queries

Hi All, I have written 4 sql queries . Now I want to write one SHELL SCRIPTING program for all these queries... i.e 1.select * from head; 2. select * from detail; 3. delete from head; 4. delete from detail; Please let me know how to write a shell script... Thank you (1 Reply)
Discussion started by: user71408
1 Replies

4. Shell Programming and Scripting

Nested SQL queries within Shell script

Hi, Would someone know if I can fire nested sql queries in a shell script? Basically what I am trying to do is as follows: my_sql=$(sqlplus -s /nolog<<EOF|sed -e "s/Connected. *//g" connect... (2 Replies)
Discussion started by: shrutihardas
2 Replies

5. Shell Programming and Scripting

Script is not working from cron while working manually

Hello, I am facing a very strange problem when I run my script manuallu ./Fetchcode which is using to connect with MKS integrity from linux end it workks fine but when I run it from cron it doesn't work.Can someone help me 1) How could I check my script when it is running from cron like... (3 Replies)
Discussion started by: anuragpgtgerman
3 Replies

6. Shell Programming and Scripting

Script not working in cron but working fine manually

Help. My script is working fine when executed manually but the cron seems not to catch up the command when registered. The script is as follow: #!/bin/sh for file in file_1.txt file_2.txt file_3.txt do awk '{ print "0" }' $file > tmp.tmp mv tmp.tmp $file done And the cron... (2 Replies)
Discussion started by: jasperux
2 Replies

7. Shell Programming and Scripting

Executing set of sql queries from shell script

Hi All, I tried executing set of queries from shell script but not able to capture the input query in the log file. The code looks something similar to below sqlplus user/pwd@dbname << EOF > output.log $(<inputfile.txt) EOF The above code is capturing the output of queries into... (9 Replies)
Discussion started by: loggedin.ksh
9 Replies

8. Shell Programming and Scripting

How can i run sql queries from UNIX shell script and retrieve data into text docs of UNIX?

Please share the doc asap as very urgently required. (1 Reply)
Discussion started by: 24ajay
1 Replies

9. Shell Programming and Scripting

run sql queries from UNIX shell script.

How can i run sql queries from UNIX shell script and retrieve data into text docs of UNIX? :confused: (1 Reply)
Discussion started by: 24ajay
1 Replies

10. Shell Programming and Scripting

Storing multiple sql queries output into variable by running sql command only once

Hi All, I want to run multiple sql queries and store the data in variable but i want to use sql command only once. Is there a way without running sql command twice and storing.Please advise. Eg : Select 'Query 1 output' from dual; Select 'Query 2 output' from dual; I want to... (3 Replies)
Discussion started by: Rokkesh
3 Replies
DRUSH(1)						      General Commands Manual							  DRUSH(1)

NAME
drush - shell scripting interface for Drupal SYNOPSIS
drush [options] command... DESCRIPTION
drush is a veritable Swiss Army knife designed to make life easier for those of us who spend some of our working hours hacking away at the command prompt. Drush core ships with lots of useful commands for interacting with code like modules/themes/profiles. Similarly, it runs update.php, exe- cutes sql queries and DB migrations, and misc utilities like run cron or clear cache. OPTIONS
-r path, --root=path Drupal root directory to use (default: current directory) -l uri, --uri=uri URI of the drupal site to use (only needed in multisite environments) -v, --verbose Display extra information about the command. -q, --quiet Hide all output -d, --debug Display even more information, including internal messages. -y, --yes Assume 'yes' as answer to all prompts -s, --simulate Simulate all relevant actions (don't actually change the system) -p, --pipe Emit a compact representation of the command for scripting. -h, --help A detailed help system, use drush help help for complete help. --version Show drush version. If you get tired of typing options all the time, you can add them to your drush.php alias or create a drushrc.php file. These provide addi- tional options for your drush call. They provide great flexibility for a multi-site installation, for example. See example.drushrc.php. COMMANDS
Drush is all based around "commands" that are usually defined in various modules. help Print the help message. Use --filter to limit command list to one command file (e.g. --filter=pm). cache-clear (cc) Clear a specific cache, or all drupal caches. core-cli (cli) Enter a new shell optimized for Drush use. core-cron (cron) Run all cron hooks. core-status (st) Provides a birds-eye view of the current Drupal installation, if any. php-eval (eval) Evaluate arbitrary php code after bootstrapping Drupal. updatedb (updb) Apply any database updates required (as with running update.php). variable-get (vget) Get a list of some or all site variables and values variable-set (vset) Set a variable. watchdog show Shows recent watchdog log messages. Optionally filter for a specific type. pm-enable (en) Enable one or more extensions (modules or themes). pm-disable (dis) Disable one or more extensions (modules or themes). pm-download (dl) Download projects from drupal.org or other sources. pm-uninstall Uninstall one or more modules. pm-updatecode (upc) Update Drupal core and contrib projects to latest recommended releases. pm-update (up) Update Drupal core and contrib projects and apply any pending database updates (Same as pm-updatecode + updatedb). sql-cli (sqlc) Open a SQL command-line interface using Drupal's credentials. sql-connect A string for connecting to the DB. sql-dump Exports the Drupal DB as SQL using mysqldump. This manual only lists a few of the most frequently used builtin commands shipped with the Drush core, since other Drupal modules and third-party "command files" may extend this list significantly. The canonical source of information for the available commands and their usage is the online help system. More information on each command is also available through drush help <command>. Most commands have shortcuts indicated in parenthesis. FILES
/etc/drush/drushrc.php /usr/share/doc/drush/examples/example.drushrc.php SEE ALSO
cvs(1), svn(1), wget(1). AUTHOR
Drush was originally developed by Arto for Drupal 4.7 (this alpha code can still be found in the DRUPAL-4-7 branch). In May 2007, it was partly rewritten and redesigned for Drupal 5 by frando. Since 2008, the module has been maintained by Moshe Weitzman, Owen Barton and Adrian Rossouw. This manual page was written by Antoine Beaupre <anarcat@debian.org> in June 2009 for the Debian project (but may be used by others). January 11, 2011 DRUSH(1)
All times are GMT -4. The time now is 09:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy