Different output when running in different way.


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Different output when running in different way.
# 1  
Old 05-14-2014
Tools Different output when running in different way.

Hi,
I have a script which when i run in manually it runs properly, but when i run the same script using UC4 scheduler it dose not run properly.

Below is the code i am using. i am not sure what is happening when i run this through UC4 the files are not generated. but when i run this manually it works fine.

Code:
## The below path is defined for config file.
. /****/****/****/****/****/****/.config_****.env

## Below variables are populated from the config file defined above.
DBUSER=$DBUSR
DBPASS=$DBPWD
SYSID=$SYSTEMID
tgtpath=$path
tablenamepath=$Tablenamefilepath
TABLE_FILE=$Table_NAME_EXTERNALID
logfile=$errorlog
Emailuser_BE=$Emailuser_BE
Emailuser_NL=$Emailuser_NL
Emailuser_DK=$Emailuser_DK
zippath=$zippath
logfiledirectory=$log_dir


## Below variable is assigned from the argument passed while executing the script.
Countrycode=$1


## Below variables are assigned dynamically as and when the script is called
allfile=FF_ErrorReport_****_$(date +"%Y%m%d%H%M")_${Countrycode}.csv
allfilezip=FF_ErrorReport_****_$(date +"%Y%m%d%H%M")_${Countrycode}.csv.zip
time=$(date +"%Y%m%d%H%M%S")
today=$(date +"%Y%m%d")



if [ $Countrycode == **** ]
then
Emailuser=$Emailuser_****
CountryName=****
elif [ $Countrycode == **** ]
then
Emailuser=$Emailuser_****
CountryName=****
elif [ $Countrycode == **** ]
then
Emailuser=$Emailuser_****
CountryName=****
elif [ $Countrycode == **** ]
then
Emailuser=$Emailuser_****
CountryName=****
elif [ $Countrycode == **** ]
then
Emailuser=$Emailuser_****
CountryName=****
elif [ $Countrycode == **** ]
then
Emailuser=$Emailuser_****
CountryName=****
else
echo 'Please enter country code as either BE, NL or DK these are the country codes present in BENO. If you want to generate the file for any other OPU please contact the L2 support team.'
fi


email_with_attachment ()
{
email_body=" 
Hi All,\n
\n
**** Code $Countrycode\n
\n
   Reject Report File Name:$allfile\n
\n 
   Execution Time=$time\n
\n
This email is automatically generated. Please do not reply.\n
\n
Best Regards\n
-Integration Team "

(echo -e ${email_body};uuencode $zippath$allfilezip $allfilezip) | mail -s "The $allfile file is generated and mail is sent for $(date +"%Y%m%d") run for $CountryName is successful." $Emailuser

}
## End of email_with_attachment function




email_without_attachment ()
{
email_body=" 
Hi All,\n
\n
The Target file generated for today's run was more than 10 MB, so it is not attached. Please find the reject report in the following path:\n
\n
   Reject Report File Name:$zippath
\n
   Reject Report File Name:$allfile\n
\n 
   Execution Time=$time\n
\n
This email is automatically generated. Please do not reply.\n
\n
Best Regards\n
-Integration Team "

(echo -e ${email_body}) | mail -s "The $allfile file is generated and mail is sent for $(date +"%Y%m%d") run for $CountryName is successful." $Emailuser

}
## End of email_without_attachment function



## The below function is defined to log into the database and get the data according to the sql query.
errorsql () 
{

errorreport=FF_ErrorReport_Veeva

## This function is the InitCap function for unix
firstvalue=`echo $2 | awk -F"\_" '{print $3}' | awk '{print toupper(substr($1,1,1)) tolower(substr($1,2))}'`
secondvalue=`echo $2 | awk -F"\_" '{print $4}' | awk '{print toupper(substr($1,1,1)) tolower(substr($1,2))}'`
thirdvalue=`echo $2 | awk -F"\_" '{print $5}' | awk '{print toupper(substr($1,1,1)) tolower(substr($1,2))}'`
fourthvalue=`echo $2 | awk -F"\_" '{print $6}' | awk '{print toupper(substr($1,1,1)) tolower(substr($1,2))}'`

interfacename="${firstvalue}${secondvalue}${thirdvalue}${fourthvalue}"

tgtfile="${errorreport}_${interfacename}"_Load_$(date +"%Y%m%d%H%M%S")_${Countrycode}_BENO.csv

sqlplus -s $DBUSER/$DBPASS@$SYSID >  $logfiledirectory/$logfile  << EOF
SET HEADING OFF
SET SERVEROUTPUT ON
SET VERIFY OFF
SET TERMOUT OFF
SET TRIMSPOOL OFF
SET FEEDBACK OFF
SET LINESIZE 5000
WHENEVER SQLERROR EXIT FAILURE;
spool  $tgtpath/$tgtfile
SELECT 'EXTERNAL_ID_VOD__C,T_SRC_COUNTRY,T_SRC_SYSTEM,T_REC_ACTION,T_STATUS,T_REC_CREATE_DT,T_ETL_JOB_ID,T_REC_UPDATE_DT,T_LAYER_INDCTR,T_REJECT_REASON' FROM DUAL;
SELECT $3||','||T_SRC_COUNTRY||','||T_SRC_SYSTEM||','||T_REC_ACTION||','||T_STATUS||','||T_REC_CREATE_DT||','||T_ETL_JOB_ID||','||T_REC_UPDATE_DT||','||T_LAYER_INDCTR||','||T_REJECT_REASON 
FROM CRM_ODS_BX.$2 
WHERE T_STATUS = 'OPEN' 
AND T_LAYER_INDCTR IN ('ODS','VEEVA')
AND T_SRC_COUNTRY = '$1'
AND $3 IS NOT NULL;
spool off

EOF

}



 table which ********.
for i in `cat ${tablenamepath}/${TABLE_FILE}`
do
tablename=`echo $i | cut -d "," -f1`
externalid=`echo $i | cut -d "," -f2`
errorsql $Countrycode $tablename $externalid
done
## End of for loop.



zip -9 -r $zippath$allfilezip $tgtpath/FF_ErrorReport_Veeva*$today*_${Countrycode}_BENO.csv



Filesize=`ls -ltr $zippath$allfilezip | cut -d ' ' -f5`



if [ $Filesize -le 10485760 ]
then
email_with_attachment
else
email_without_attachment
fi

# 2  
Old 05-14-2014
In what way does it not "run properly"? What, exactly, does it do?
# 3  
Old 05-15-2014
the thing is when i run this file in UNIX it logs into the DB and generate the files. but in same way when i run it using the UC4 scheduler the files are not getting generated but m getting the mail saying the files are more that 10MB and present in the path.
# 4  
Old 05-15-2014
So the scheduler (UC4 in your case) is setting up the environment to run the script. It is possible that it either sets a quota or a limit on filesize to protect you from a runaway process. Can you schedule something to capture the environment to a file and then compare that to a login user? Something like a script containing:-
Code:
env|sort>/tmp/$$

Of course, this should allow for any environment scripts you source in as your normal scheduled scripts are starting up.


I hope that this helps. Let us know what you find (or not)



Robin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Unable to get output in mail body after running cron

I have prepared script to get the file details everyday and send mail. while running bash script manually , it sends output in body . but does not send through cron. cron sends only subject . I believe have to use some wait or sleep syntex. to complete first . please help. #!/bin/bash ls... (10 Replies)
Discussion started by: yash_message
10 Replies

2. Programming

Running java script from piped output

to run most other scripts through a pipe, something similar to the following is usually enough: cat script.sh | sh cat perl.pl | perl -- "<arguments" However, for javascript command line scripts, i cant seem to get this to work. Any ideas? cat hull.js #!/usr/bin/js ... (3 Replies)
Discussion started by: SkySmart
3 Replies

3. HP-UX

PS output is not displaying full process running

I have 4 HPUX 11.31 servers with the same Quality Pack bundles. "AS FAR AS I CAN TELL" no system files have been modified. /usr/bin/ps is the same date size and creation date terminfo file (x-->xterm) is the same date size and creation date shell (ksh) is the same date size and creation date ... (4 Replies)
Discussion started by: mrmurdock
4 Replies

4. Shell Programming and Scripting

Running same script through cron gives different output

Hi All, I am running the below shell script through cron and surprisingly it gives different output $uname -a Linux 2.6.18-194.3.1.7.3.el5xen #1 SMP Fri Jul 30 00:08:45 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux $ echo $SHELL /bin/bash shell script: cat sar_cpu.sh #!/bin/bash ... (10 Replies)
Discussion started by: a1_win
10 Replies

5. Shell Programming and Scripting

running C program to output in multiple locations

Hi Guys, What I am looking at doing is to run a C program in my home directory, but output files in multiple directories BUT not at the same instance. For e.g. 1st instance: Run program.c and output results in path /aaa/bbb/ccc/ 2nd instance: Run program.c again and output results... (9 Replies)
Discussion started by: Jatsui
9 Replies

6. UNIX for Dummies Questions & Answers

sftp output is different when running manually/script

When I manually run a sftp to a remote server I receive the following output on he screen; Uploading filename to /inbound/xxxxxxx_Folder_1/filename filename 100% 50 0.1KB/s ... (1 Reply)
Discussion started by: rugggy
1 Replies

7. Shell Programming and Scripting

sftp output is different when running manually/script

When I manually sftp a file to a remote server I get the following output on the screen; Uploading filename to /inbound/xxxxxxx_Folder_1/filename filename 100% 50 0.1KB/s 00:00 When I run the commands from within a shell script I do not get the "filename ... (0 Replies)
Discussion started by: rugggy
0 Replies

8. Shell Programming and Scripting

Script not running from cron it gives blank output

Hi, I have ascript which drops a mail with the jobs status. here is the script: #!/bin/ksh mypath=/home/gaddamja flashlogpath=/sbcimp/dyn/data/flash/log cd $mypath v1=`ls -lrt | grep -i checkFilesForAmber_EUR1. |tail -1 | awk '{print $8}'` v2=`cat $v1` cd $flashlogpath ... (1 Reply)
Discussion started by: jagadish_gaddam
1 Replies

9. UNIX for Advanced & Expert Users

My command is still running but someone closed my shell, can I get my output still?

I ran an fs_usage (based off dtrace facility) but someone closed the window I think.. But I still see the process running # 15023 I tried fg 15023 but it told me no job control.. Is there anyway I can see my output? The scan has been running an hour and the output is valuable to me. (3 Replies)
Discussion started by: glev2005
3 Replies

10. Shell Programming and Scripting

piping output of tail running in background

Not sure why this does not work in bash: tail -f err.log |& -bash: syntax error near unexpected token `&' I am attempting to continuously read a file that is being updated by doing a "tail -f" on the file and piping the output to stdin which can then be read by the next shell command Thnx (4 Replies)
Discussion started by: anuramdas
4 Replies
Login or Register to Ask a Question