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...
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.
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)