Shell script works fine as a standalone script but not as part of a bigger script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell script works fine as a standalone script but not as part of a bigger script
# 1  
Old 07-11-2017
Shell script works fine as a standalone script but not as part of a bigger script

Hello all,

I am facing a weird issue while executing a code below -

Code:
#!/bin/bash
cd /wload/baot/home/baotasa0/sandboxes_finance/ext_ukba_bde/pset
sh UKBA_publish.sh UKBA 28082015 3
if [ $? -eq 0 ]
then
echo "Param file conversion for all the areas are completed, please check in your home directory"
else
echo "The final PSET failed"
fi

When I execute it as a standalone code it works fine but when I execute it as a part of below mentioned script, it fails -

Code:
#!/bin/bash
param1=$1
param2=$2
param3=$3
email=$4
baot_id=$5
header_date_14=$(m_dump /wload/baot/app/data_abinitio/serial/uk_cust/ukrb_ukba_acnt_bde27_src.dml $param1 | head -35)
hdr_dt_14=$(echo "$header_date_14" | awk '$1=="bdfo_run_date" {print $2}')
julian_date_14=$(m_eval '(date("YYYYMMDD"))( unsigned integer(2)) '$hdr_dt_14'') 2>&1
header_date_15=$(m_dump /wload/baot/app/data_abinitio/serial/uk_cust/ukrb_ukba_acnt_bde27_src.dml $param2 | head -35)
hdr_dt_15=$(echo "$header_date_15" | awk '$1=="bdfo_run_date" {print $2}')
julian_date_15=$(m_eval '(date("YYYYMMDD"))( unsigned integer(2)) '$hdr_dt_15'')
header_date_16=$(m_dump /wload/baot/app/data_abinitio/serial/uk_cust/ukrb_ukba_acnt_bde27_src.dml $param3 | head -35)
hdr_dt_16=$(echo "$header_date_16" | awk '$1=="bdfo_run_date" {print $2}')
julian_date_16=$(m_eval '(date("YYYYMMDD"))( unsigned integer(2)) '$hdr_dt_16'')
echo "This is your Header date $julian_date_16"
if [ "$julian_date_14" = "$julian_date_15" -a "$julian_date_15" = "$julian_date_16" ]
then
echo All the dates from three input files are same
else
echo Check the file dates please
fi
cd /wload/baot/home/baotasa0/sandboxes_finance/ext_ukba_bde/pset
Param_date=`echo $DATE_FINAL | cut -c7-8`
Param_month=`echo $DATE_FINAL | cut -c5-6`
Param_year=`echo $DATE_FINAL | cut -c1-4`
Param_date_1="$Param_date$Param_month$Param_year"
echo "Date to execute final PSET is $Param_date_1"
sh UKBA_publish.sh UKBA Date_FINAL 3
if [ $? -eq 0 ]
then
echo "Param file conversion for all the areas are completed, please check in your home directory"
else
echo "The final PSET failed"
fi
cd /wload/baot/app/data_abinitio/abinitio_UKBA_BDE_PUB_DISK/mfs/mfs_6way/EXTRACTS/UKBA/ext_ukba_bde_pub/main/daily
m_cp *$DATE_FINAL.SNAP.gz /wload/baot/home/$baot_id
cd
m_gunzip *20150828.SNAP.gz

Param1,Param2, Param3 and Param 4, Param 5 are required as a command line arguments.
Error is below -

Code:
Trouble creating layout "layout-Process_DETAIL.Rollup_to_account_level_within_files":

Failed computing working directory: No such file or directory
  Path = "mfile:/wload/baot/app/data_abinitio/abinitio_PBE_DISK/mfs/mfs_6way/EXTRACTS/UKBA/ext_ukba_bde/main/."

air sandbox run ukba_bde_validation_publish_ebcdic_TEST.pset failed
The final PSET failed

My point is why this code works as a standalone one and not with a script in the same environment. LinuxLinuxLinux
I am using AIX.
Any pointers will be greatly appreciated.

---------- Post updated at 08:38 AM ---------- Previous update was at 05:22 AM ----------

@VBE

Code:
sh UKBA_publish.sh UKBA Date_FINAL 3

should it not be:
Code:
 sh UKBA_publish.sh UKBA $Date_FINAL 3  ?

No, since script accepts 3 parameters, UKBA is area name and has to be hardcoded, date is the date, 3 is number of files.

Last edited by vbe; 07-11-2017 at 01:15 PM.. Reason: code tags...
# 2  
Old 07-11-2017
You do realize that the two are not the same in that the bigger script attempts to extract parameters.
You seem to be using two different methods to build your variables:

Code:
header_date_14=$( ...

and

Code:
Param_date=` ...

You may want to re-write the 2nd set to be in the format as the 1st set. I remember there being some caveats/warnings about the use of each.
# 3  
Old 07-11-2017
Quote:
Code:
sh UKBA_publish.sh UKBA Date_FINAL 3

should it not be:
sh UKBA_publish.sh UKBA $Date_FINAL 3 ?

No, since script accepts 3 parameters, UKBA is area name and has to be hardcoded, date is the date, 3 is number of files.
I know very well you give 3 parameters... When I added that remark its because in your attempt:
Code:
sh UKBA_publish.sh UKBA 28082015 3

You entered a value for your second whereas
Code:
sh UKBA_publish.sh UKBA Date_FINAL 3

you give a string not a VARIABLE...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed command not working inside ksh script but works fine outside

Hi, I am a bit confused ,why would a sed command work fine outside of ksh script but not inside. e.g I want to replace all the characters which end with a value and have space at end of it. so my command for it is : sed -i "s/$SEPARATOR /$SEPARATOR/g" file_name This is working fine in... (8 Replies)
Discussion started by: vital_parsley
8 Replies

2. Shell Programming and Scripting

Part of the Shell script is not running via crontab, runs fine manually

Hello Team, As a part of my job we have made a script to automate a service to restart frequently. Script having two functions when executing it's should find the existing service and kill it, then start the same service . Verified the script it's working fine when executing... (18 Replies)
Discussion started by: gowthamakanthan
18 Replies

3. Shell Programming and Scripting

Shell script not getting called through cron job but executes fine manually.

Hi, My shell script not getting called through cron job. The same works fine when executed manually. I tried to generate logs to find if the scripts has some errors related to path using following command- trying to execute .sh file every 5 mins: */5 * * * * /home/myfolder/abc.sh... (17 Replies)
Discussion started by: Dejavu20
17 Replies

4. Shell Programming and Scripting

Not the correct output, works fine via CLI, not inside the script.

Guys, I need you help please. The script below is not working correclty for checking via a awk/if statement . Can you tell me what i am doing wrong in the script code "if($1 == "$RETENTION_LEVEL") " Syntax RETENTION_LEVEL=`echo $LINE | cut -f2 -d" "` echo " ==============... (4 Replies)
Discussion started by: Junes
4 Replies

5. Shell Programming and Scripting

Sed script not working properly on Solaris (works fine on AIX)?

Hi, I have a problem with a SED script that works fine on AIX but does not work properly on a Solaris system. The ksh script executes the SED and puts the output in HTML in tables. But the layout of the output in HTML is not shown correctly(no tables, no color). Can anyone tell if there is... (7 Replies)
Discussion started by: Faith111
7 Replies

6. Shell Programming and Scripting

Script works fine but not with crontab

Hello All, This is driving me nuts. Wrote a very simple script (it's in csh so sorry about that). Just something very simple though. Here is the catch. Works great from command line sometimes. Other times it runs no errors or anything but I never receive an email. Never runs from crontab... (6 Replies)
Discussion started by: jacktay
6 Replies

7. Shell Programming and Scripting

Shell script runs fine in Solaris, in Linux hangs at wait command

HI, I have a strange problem. A shell script that runs fine on solaris. when i ported to linux, it started hanging. here is the core of the script CFG_FILE=tab25.cfg sort -t "!" -k 2 ${CFG_FILE} | egrep -v "^#|^$" | while IFS="!" read a b c do #echo "jobs output" #jobs #echo "jobs... (13 Replies)
Discussion started by: aksaravanan
13 Replies

8. Shell Programming and Scripting

Works in shell but not script UNIX

ok i have a very simple UNIX script #!/bin/bash TERM=ansi;export TERM PFCMARK=25;export PFCMARK umask 0000 PFUMASK=000;export PFUMASK #run for filepro menus and exectuables echo "###########File Modification Log.############\r" > "/public/appl-fp$(date +%m-%d-%Y).txt" find /appl/fp/... (10 Replies)
Discussion started by: dunpealslyr
10 Replies

9. Shell Programming and Scripting

how can i print the output of the shell script in bigger size

how can i print the output of the shell script in bigger size eg: echo " hello world" i want to print this in the output with bigger size in the middle of the screen. can someone please help me out in that (2 Replies)
Discussion started by: mail2sant
2 Replies

10. Shell Programming and Scripting

Script works fine until I | more

Hello all, This beats me. I have a script that executes some commands and redirects their output to some text files that I will parse. The commands are along the lines of: dsmadmc -id=admin -pa=admin -outfile=/home/tools/qlog.txt q log f=d If I just run the script it works. If I execute... (2 Replies)
Discussion started by: Skovian
2 Replies
Login or Register to Ask a Question