Re: What does the script do
From: Lew Pitcher (lpitcher_at_sympatico.ca)
Date: 08/19/05
- Next message: Grant: "Re: hidding the content of a script"
- Previous message: matt_left_coast: "Re: hidding the content of a script"
- In reply to: sheldon.robinson_at_gmail.com: "What does the script do"
- Next in thread: Bill Seivert: "Re: What does the script do"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 18 Aug 2005 20:17:35 -0400
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
sheldon.robinson@gmail.com wrote:
> Will it execute the lines following the if.. clause or the then..
> clause?
Yes.
>
> if [ $LINE_COUNT -lt 1 ]
> cd ${BATCH10_DIR}/data/outgoing/file43
> mv bqt_sspmog_file43* ${BATCH10_DIR}/data/processed/
> cd ${BATCH10_DIR}
> then
> . ${BATCH10_DIR}/sendmail.sh $TO_MAILID "BQT-SSP File43 FTPed
> successfully" $LOG_FILE
> fi
In general, the [ba]sh 'if' statement is stuctured as
if <list of statements>
then <list of statements>
[ else <list of statements> ]
fi
with some variations for an else-if component
Your example if statement falls into the general format quite nicely
The first part
if [ $LINE_COUNT -lt 1 ]
cd ${BATCH10_DIR}/data/outgoing/file43
mv bqt_sspmog_file43* ${BATCH10_DIR}/data/processed/
cd ${BATCH10_DIR}
matches to
if <list of statements>
The next part
then
. ${BATCH10_DIR}/sendmail.sh $TO_MAILID \
"BQT-SSP File43 FTPed successfully" $LOG_FILE
matches to
then <list of statements>
And, of course, the final part
fi
matches to
fi
So, if the exit status of the list of commands
[ $LINE_COUNT -lt 1 ]
cd ${BATCH10_DIR}/data/outgoing/file43
mv bqt_sspmog_file43* ${BATCH10_DIR}/data/processed/
cd ${BATCH10_DIR}
is 0, then
. ${BATCH10_DIR}/sendmail.sh $TO_MAILID \
"BQT-SSP File43 FTPed successfully" $LOG_FILE
will be executed
- --
Lew Pitcher
Master Codewright & JOAT-in-training | GPG public key available on request
Registered Linux User #112576 (http://counter.li.org/)
Slackware - Because I know what I'm doing.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.7 (GNU/Linux)
iD8DBQFDBSUeagVFX4UWr64RAoaJAKDpzZeucLf3HeFC760xZyxpgCE//QCg6pI+
xGkiBjBdV5ZVhJHvuy1yZs8=
=oImH
-----END PGP SIGNATURE-----
- Next message: Grant: "Re: hidding the content of a script"
- Previous message: matt_left_coast: "Re: hidding the content of a script"
- In reply to: sheldon.robinson_at_gmail.com: "What does the script do"
- Next in thread: Bill Seivert: "Re: What does the script do"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|