The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help Required: Command to find IP address and command executed of a user loggedout Security 2 08-06-2008 05:12 PM
how to? launch command with string of command line options TinCanFury Shell Programming and Scripting 5 04-28-2008 03:06 PM
inconsistent ls command display at the command prompt & running as a cron job rajranibl Linux 5 07-30-2007 05:26 AM
How to use more than one MPE command STREAM with Unix command in a single shell? bosskr HP-UX 1 10-16-2006 01:16 PM
How to use more than one MPE command STREAM with Unix command in a single shell? bosskr Shell Programming and Scripting 0 09-19-2006 06:44 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 11-20-2007
Registered User
 

Join Date: Mar 2007
Posts: 8
Or command

I am having trouble with an Or command in my UNIX script.
It is as follows:
Quote:
for i in `cat ${OUT_DIR}/holdfile`
do
#Check each file has the correct name begins with PACK or LETT
LETTYPE=`expr substr $i 1 4`
echo "$LETTYPE" >> dan.txt
#if [ "$LETTYPE" != LETT -o "$LETTYPE" != PACK ]
if [ "$LETTYPE" != LETT || "$LETTYPE" != PACK ]
then
echo "Invalid file name, look at ${OUT_FILE}/holdfile" >> ${LOGFILE}
exit 1
else
echo "Valid file names for processing" >> ${LOGFILE}
fi
done
The run never fails even if I put one not beginning with LETT or PACK.
The holdfile is correct and putting out the right result and the dan.txt is also right stripping the first 4 characters off each file name.
Any ideas?
Reply With Quote
Forum Sponsor
  #2  
Old 11-20-2007
grial's Avatar
El UNIX es como un toro
 

Join Date: Jun 2006
Location: Madrid (Spain)
Posts: 531
I would use "case" instead:
Code:
for i in `cat ${OUT_DIR}/holdfile`
do
#Check each file has the correct name begins with PACK or LETT
LETTYPE=`expr substr $i 1 4`
echo "$LETTYPE" >> dan.txt
case $LETTYPE in
LETT|PACK)
      # Do nothing.
      :;;
   *)
      # Exit.
      echo "Invalid file name, look at holdfile ($i)"
      exit 1
      ;;
   esac
done
echo "Valid file names for processing" >> ${LOGFILE}
Regards.
Reply With Quote
  #3  
Old 11-20-2007
Registered User
 

Join Date: Mar 2007
Posts: 8
Thanks for that I've got it working
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:28 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0