The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Date Validation: satyam_sat Shell Programming and Scripting 1 04-02-2008 03:17 AM
how do I make dynamic parameter names? Or get the value of a parameter evaluated twi Awanka Shell Programming and Scripting 2 04-19-2007 06:37 PM
Filename Validation F-1 UNIX for Advanced & Expert Users 2 05-02-2006 10:29 AM
Data Validation ericelysia UNIX for Dummies Questions & Answers 2 12-15-2005 05:06 AM
String validation DeepakXavier Shell Programming and Scripting 3 10-09-2005 07:43 PM

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

Join Date: Apr 2008
Posts: 1
validation on a parameter

Hi guys!
Im tryin to set up a login script that allows a user to login with only the following "forename.surname" .

The username all contain lowercase letters so thats not a problem to sort out, but im having problems making sure that they can only enter 1 " . " . the code i have so far is this which i thought should work but always comes out as false:

Code:
file=$1

if [ "$file" != '[a-z]\.' ]
then
	echo File must contain a dot!
fi
exit 0

if [ "$file" = '[a-z]\..' ]
then
	echo File must contain no more than 1 dot!
fi
exit 0
Also how do i search the string so that a char can come in any order?
Please help feel so thick!
Reply With Quote
Forum Sponsor
  #2  
Old 04-20-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
Try the trusty old case statement.

Code:
case $file in
  *.*.*) echo Many dots;;
  *.*) echo Fine;;
  *) echo No dots;;
esac
The idea to write a shell script to control login sounds rather iffy, though. What happens if somebody types ctrl-C in the middle of your script? (It can be trapped, but there are other more sinister scenarios down that chute.)
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 07:36 PM.


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