Tag Archives: SH

Issue with cron and environmental variable

By rafa_fed2

My shell script it.sh.I am calling bip.sh from it.sh

Code:

#!/bin/sh
ORACLE_HOME=/var/opt/oracle/product/10g; export ORACLE_HOME
PATH=$PATH:$ORACLE_HOME/bin:/bin:/usr/bin; export PATH
today=`date "+%m-%d-%Y %H:%M:%S"`; export today
CUR_DIR=$1; export CUR_DIR

LOG_FILE=$CUR_DIR/error.log; export LOG_FILE

# Direct script output to log
exec > $LOG_FILE 2>&1

echo
echo
echo "LOGGING STARTS $today"
echo
echo
###Fetching the script directory from configuration file
SCRIPT_DIR=`cat $CUR_DIR/.id_pass_file.txt | grep "^SCRIPT_DIR" | cut -d "=" -f2`; export SCRIPT_DIR

### Credentials for SQLPLUS

USER_ID=`cat $CUR_DIR/.id_pass_file.txt | grep "^USER_ID" | cut -d "=" -f2`; export USER_ID
PWD=`cat $CUR_DIR/.id_pass_file.txt | grep "^PWD" | cut -d "=" -f2`; export PWD
SID=`cat $CUR_DIR/.id_pass_file.txt | grep "^SID" | cut -d "=" -f2`; export SID

### Connecting ORACLE

echo "SQLPLUS CONNECTION"

sqlplus -s $USER_ID@$SID/$PWD<$CUR_DIR/sql_output.txt
set feedback off
set heading off
select 1016 from adj where rownum <2;
EOF

if [ $? -eq 0 ]
then
echo " SQLPLUS Connection Successful "
else
echo " SQLPLUS Connection Failed "
fi

##echo " The account numbers to be used in BIP are "

if [ ! -s "$CUR_DIR/sql_output.txt" ]
then
echo "No account number for bad debt"
else
for i in `cat $CUR_DIR/sql_output.txt`
do
echo "bip $i is running"
cd $SCRIPT_DIR
sh bip.sh 01 0 $i > $CUR_DIR/bip_log_1.txt
sleep 100
done
fi

###Removing temporary log files generated

if [ -f $CUR_DIR/bip_log_1.txt ]
then
`rm $CUR_DIR/bip_log_1.txt`
echo "file bip__log_1.txt removed"
fi

if [ -f $CUR_DIR/sql_output.txt ]
then
`rm $CUR_DIR/sql_output.txt`
echo "sql_output.txt removed"
fi


Code:

59 04 * * * /arbor/integ_fx/rahul_raj/itsr_5652/it.sh /arbor/integ_fx/rahul_raj/itsr_5652


my error.log file

Code:

LOGGING STARTS 07-22-2013 05:22:00

SQLPLUS CONNECTION
SQLPLUS Connection Successful
bip 1016 is running
cat: cannot open /.arborpw
file bip__log_1.txt removed
sql_output.txt removed.
ERROR: $ARBORDBU environment variable is not set

This script requires that the $ARBORDBU environment variable be set.


MY BIP.SH

Code:

#!/bin/sh
ARBOR_DB_PASSWD=`cat $ARBORDIR/.arborpw`; export ARBOR_DB_PASSWD
DB_PASS=$ARBOR_DB_PASSWD; export DB_PASS;
ORACLE_SID=$ARBOR_CATALOG_DATABASE; export ORACLE_SID;
ARBORCTRLRPT03=$ARBORDATA/reports/ctrl; export ARBORCTRLRPT03;

Usage(){
echo "nn Usage is: `basename $0` n"
echo " where is a number between 01 and 99"
echo " is a number. Use 0=production, 3=proforma, 6=backout"
echo " is an arbor accout numbernn"
exit 0
}

# Check number of arguments
if [ "$#" -ne 3 ] ; then
Usage
fi

# Check to see if ARBORDBU is set
if [ -z "${ARBORDBU}" ] ; then
echo "ERROR: $ARBORDBU environment variable is not setn"
echo "This script requires that the $ARBORDBU environment variable be set.nn"<br ...read more

Source: FULL ARTICLE at The UNIX and Linux Forums

Scheduling issues

By rafa_fed2

I AM ON SOLARIS

I have a script it.sh which is running fine when i execute it from shell command.
But when i schedule it in crontab it is throwing error.

Why and how can i resolve it ?i am clueless

IT.SH

Code:

#!/bin/sh
ORACLE_HOME=/var/opt/oracle/product/10g; export ORACLE_HOME
PATH=$PATH:$ORACLE_HOME/bin:/bin:/usr/bin; export PATH
today=`date "+%m-%d-%Y %H:%M:%S"`; export today
CUR_DIR=$1; export CUR_DIR

LOG_FILE=$CUR_DIR/error.log; export LOG_FILE

# Direct script output to log
exec > $LOG_FILE 2>&1

echo
echo
echo "LOGGING STARTS $today"
echo
echo
###Fetching the script directory from configuration file
SCRIPT_DIR=`cat $CUR_DIR/.id_pass_file.txt | grep "^SCRIPT_DIR" | cut -d "=" -f2`; export SCRIPT_DIR

### Credentials for SQLPLUS

USER_ID=`cat $CUR_DIR/.id_pass_file.txt | grep "^USER_ID" | cut -d "=" -f2`; export USER_ID
PWD=`cat $CUR_DIR/.id_pass_file.txt | grep "^PWD" | cut -d "=" -f2`; export PWD
SID=`cat $CUR_DIR/.id_pass_file.txt | grep "^SID" | cut -d "=" -f2`; export SID

### Connecting ORACLE

echo "SQLPLUS CONNECTION"

sqlplus -s $USER_ID@$SID/$PWD<$CUR_DIR/sql_output.txt
set feedback off
set heading off
select distinct account_no from adj WHERE ADJ_TRANS_CODE=-2401 and request_status=1 and bill_ref_no=0
order by account_no;
EOF

if [ $? -eq 0 ]
then
echo " SQLPLUS Connection Successful "
else
echo " SQLPLUS Connection Failed "
fi

##echo " The account numbers to be used in BIP are "

if [ ! -s "$CUR_DIR/sql_output.txt" ]
then
echo "No account number for bad debt"
else
for i in `cat $CUR_DIR/sql_output.txt`
do
echo "bip $i is running"
sh $SCRIPT_DIR/bip.sh 01 0 $i > $CUR_DIR/bip_log_1.txt
sleep 180
done
fi


My error is in error.log

Code:


LOGGING STARTS

SQLPLUS CONNECTION
SQLPLUS Connection Successful
bip 114034 is running
cat: cannot open /.arborpw


my error is bip_log_1.txt

Code:

ERROR: $ARBORDBU environment variable is not set

This script requires that the $ARBORDBU environment variable be set.


My bip.sh is

Code:

#!/bin/sh
ARBOR_DB_PASSWD=`cat $ARBORDIR/.arborpw`; export ARBOR_DB_PASSWD
DB_PASS=$ARBOR_DB_PASSWD; export DB_PASS;
ORACLE_SID=$ARBOR_CATALOG_DATABASE; export ORACLE_SID;
ARBORCTRLRPT03=$ARBORDATA/reports/ctrl; export ARBORCTRLRPT03;

Usage(){
echo "nn Usage is: `basename $0` n"
echo " where is a number between 01 and 99"
echo " is a number. Use 0=production, 3=proforma, 6=backout"
echo " is an arbor accout numbernn"
exit 0
}

# Check number of arguments
if [ "$#" -ne 3 ] ; then
Usage
fi

# Check to see if ARBORDBU is set
if [ -z "${ARBORDBU}" ] ; then
echo "ERROR: $ARBORDBU environment variable is not setn"
echo "This script requires that the $ARBORDBU environment variable be set.nn"
...read more

Source: FULL ARTICLE at The UNIX and Linux Forums

While Loop Exiting

By jerome_rajan

We are trying to design a flow so that an ETL job shouldn’t start until the previous job completes. The script we have written is

Code:

while [ `ps -ef|grep "phantom DSD.RUN job_jobName"|grep -iv -e "grep" -e "SH -c"|wc -l` -ne 0 ]; do sleep 2; done


The loop however exits even when the process is actually running. Why could this be happening?

From: http://www.unix.com/shell-programming-scripting/221769-while-loop-exiting.html

Kaman Corp. Announces Release Date for First Quarter 2013 Earnings

By Business Wirevia The Motley Fool

Filed under:

Kaman Corp. Announces Release Date for First Quarter 2013 Earnings

BLOOMFIELD, Conn.–(BUSINESS WIRE)– Kaman Corp. (NYS: KAMN) announced today that it will report its first quarter 2013 results after the stock market closes on Monday, April 29, 2013, and host a live webcast and conference call at 8:30am ET on Tuesday, April 30, 2013.

The call will be accessible by telephone at (877) 474-9504 and from outside the U.S. at (857) 244-7557; (passcode: 12032247); or, via the Internet at www.kaman.com. Please go to the website at least fifteen minutes prior to the start of the call to register, download and install any necessary audio software. A replay will also be available two hours after the call and can be accessed at (888) 286-8010 or (617) 801-6888 using the passcode: 63596531.

About Kaman Corporation

Kaman Corporation, founded in 1945 by aviation pioneer Charles H. Kaman, and headquartered in Bloomfield, Connecticut conducts business in the aerospace and industrial distribution markets. The company produces and/or markets widely used proprietary aircraft bearings and components; complex metallic and composite aerostructures for commercial, military and general aviation fixed and rotary wing aircraft; aerostructure engineering design analysis and FAA certification services; safe and arm solutions for missile and bomb systems for the U.S. and allied militaries; subcontract helicopter work; and support for the company’s SH-2G Super Seasprite maritime helicopters and K-MAX medium-to-heavy lift helicopters. The company is a leading distributor of industrial parts, and operates more than 200 customer service centers and five distribution centers across North America. Kaman offers more than four million items including bearings, mechanical power transmission, electrical, material handling, motion control, fluid power, automation and MRO supplies to customers in virtually every industry. Additionally, Kaman provides engineering, design and support for automation, electrical, linear, hydraulic and pneumatic systems as well as belting and rubber fabrication, customized mechanical services, hose assemblies, repair, fluid analysis and motor management. More information is available at  www.kaman.com .

Kaman Corporation
Eric Remington, 860-243-6334
VP, Investor Relations
Eric.Remington@kaman.com

KEYWORDS:   United States  North America  Connecticut

INDUSTRY KEYWORDS:

The article Kaman Corp. Announces Release Date for First Quarter 2013 Earnings originally appeared on Fool.com.

Try any of our Foolish newsletter …read more

Source: FULL ARTICLE at DailyFinance

China Approves Ping An Stake Sale to Thai Conglomerate

HSBC Holdings PLC (0005.HK, HBC, HSBA.LN) and the Thai company buying its US$9.39 billion stake in Chinese insurer Ping An Insurance (Group) Co. (2318.HK, 601318.SH) won approval from Chinese regulators for the larger part of the deal to go ahead, ending weeks of skepticism over whether the sale would be completed.
Source: FULL ARTICLE at Fox Business Headlines

Uralkali, Belaruskali Agree to 1st Half Chinese Potash Contract For $400/Ton

Belarussian Potash Co., the trading arm for Belaruskali and Russian potash producer Uralkali (URKA.RS) agreed Monday with top Chinese importers Sinochem International Corp. (600500.SH) and CNAMPGC to a contact for 1 million metric tons of potassium chloride for $400 a ton for the first half of 2013.
Source: FULL ARTICLE at Fox Business Headlines