Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Could we kindly see all of the code so we can get the feel what you are exactly trying to do? And also, what shell are you using? One last thing I can tell is that it should be $() instead of ${}.
Edit - Nevermind on the last part..... Still waking up.....
if [[ -f ${TAR_FILENAME} ]] ; then
echo "App tar ball exist please check backup directory"
fi
# ***************************************************************
# * *
# * Create Tarball file and put it in the backup directory *
# * *
# ***************************************************************
date
tar cvf - /app/ccb/$ENV_NAME | gzip > /app/scm/dropzone/Backups/ccb/$CI/$TAR_FILENAME
if [[ $? -ne 0 ]];then
exit 1
fi
all what I want to do is check arguments like release,ci envid if they are not supplied build should fail with meaningfull message if these are present then it should check if that.tar.gz file is present(if present build should fail) if not it should proceed with doing tar of entire directory.
Well just like druuna, works for me too. Noticed you are using ksh though... Have you tried using a different shell though, like bash, just to rule it out?
Druuna beat me to it, as I was replying to another thread.... I noticed that as well, and that was the first thing that popped up in my head. Just like he said, are you getting " + exit 1" in your terminal?
yes I am aware of "+ exit 1" output which I am getting because trace is ON that is set -x.
I am not sure what shell plays the role but same code but if I change /ksh value to /bash there is an interesting observation.
Output changes from just + exit 1 to
{code}
+ [[ -z 1.9.0.6.6.12 ]]
+ [[ -z '' ]]
+ exit 1
{code}
Yes it is doing what is supposed to meaning, build fails but I am not sure of two statements.
echo "RELEASE value not supplied"
exit 1
why it just does exit 1, it should display some meaning message as well?
Read my edit in that post, I said to nevermind that.... When I wrote that, I was still waking up, and apparently my brain thought that you were trying to execute that variable for some reason. My bad!
Just curious... What distro, and version of both bash and ksh are you using?
You first parse a file which contains the $RELEASE variable (this line: . /app/scm/dropzone/$RELEASE/release_record.sh), after that is done you check for the existence of $RELEASE. If $RELEASE isn't set, the parsing part will give an error message and the script will exit at that point. No need to check for $RELEASE after the fact......
What happens if you give the following a try:
Code:
#!/bin/ksh
set -x
if [[ -z "${RELEASE}" ]]
then
echo "RELEASE value not supplied"
exit 1
fi
. /app/scm/dropzone/$RELEASE/release_record.sh
#echo $CI
#echo $ENVID
#echo $CCB_ENVNAME
if [[ -z "${CI}" ]]
then
echo "CI value not supplied"
exit 1
fi
if [[ -z "${CCB_ENVNAME}" ]]
then
echo "CCB_ENVNAME value not supplied"
exit 1
fi
export TAR_FILENAME="$CCB_ENVNAME_PRE_$RELEASE_`hostname`.tar.gz"
if [[ -f "${TAR_FILENAME}" ]]
then
echo "App tar ball exist please check backup directory"
exit 1
fi
echo "All is well"
exit 0
BTW: Do provide the info corp769 asked for. Also include the output of the following command:
drunna I agree with you, that is completely incorrect logic.
First I am parsing file to read it and source release variables and then checking for RELEASe value ! not good programming mate
we are using redhat os.
bash on source (build)server is
GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.
version sh (AT&T Research) 93s+ 2008-01-31
Red Hat Enterprise Linux Server release 5.3 (Tikanga)
on target server
I can tell easily bash version
GNU bash, version 3.00.15(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2004 Free Software Foundation, Inc.
I am unable to tell ksh version as that is what I am unable to determine.
OS
Red Hat Enterprise Linux AS release 4 (Nahant Update 7)
I do recommend upgrading to the latest and greatest, if you can. Are you a subscribed user? I say that because me and druuna aren't having problems with this...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.