Valid Name

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Valid Name
# 1  
Old 03-31-2010
Valid Name

Could someone help me by midnight tonight!!!

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:
  1. Insert a reference to the Bourne shell as the command interpreter of this shell script called valid_name.
  2. Add the appropriate comments
  3. Test that exactly one command line argruments is enter from the command line. If not, display the usage message and stop the script and set the status to 1. If exactly one is entered, continue processing.
  4. The argument enter on the command line is a first and last name ( for example: "John Smith").
  5. If the argument is a validly formatted name, you display The "name enter" is valid to standard out.
  6. If the argument is not a validly formated name, you display The "name enter" is not valid to standard out
  7. Cut and Paste you program in the space below also with a session of you executing your program with the examples provided
For Example,
$ valid_name "John Smith"
John Smith is valid
=========
$ valid_name "John smith"
John smith is not valid
=========
$ valid_name "John"
John is not valid
==========
$ valid_name "jOhn Smith"
jOhn Smith is not valid
===========
$ valid_name "John sMith"
John sMith is not valid



2. Relevant commands, code, scripts, algorithms:



3. The attempts at a solution (include all code and scripts):
#!/bin/sh

if echo $var | grep '^[A-Za-z_][A-Za-_z]*$' > /dev/null
then
echo $var "is valid"
else
echo $var "is not valid"
fi


4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):

St Clair College - Windsor Ontario
Phil Aylesworth MIT 516 Linux II - St. Clair College - Canada's Southernmost and Hottest College


Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).

Last edited by cody007; 04-01-2010 at 10:23 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Regex for a valid URL

Hi guys, What is the regex to check for only valid URL from a file using grep? (2 Replies)
Discussion started by: Meeran Rizvi
2 Replies

2. Shell Programming and Scripting

how to check for valid password

I need to check if an account has a valid password. Would something like this work? read ACCNAME if grep -q "^$ACCNAME:\$6:" /etc/shadow; thenI noticed every entry in my shadow file that has a password starts with $6 ... it works for my current setup, but would it always work? I can't test... (4 Replies)
Discussion started by: ADay2Long
4 Replies

3. UNIX for Dummies Questions & Answers

Testing for valid DC's?

Ok so this is sort of a unix question. I am frequently logging into customers boxes and our product integrates with Active directory. I deal with a great deal of people who have no business being admins but are and they don't know squat about their network or their DC's. So a recurring problem... (4 Replies)
Discussion started by: MrEddy
4 Replies

4. Shell Programming and Scripting

Specified substitution not valid for

Experts, In a script i get the following error: The specified substitution is not valid for this command Do you have any idea what is wrong with it? TITLE="Code Checker" # Script Titel # EXT="_UA99" # Eind van dirnaam # FILE="job.dat" # Zoekbestandsnaam # SEARCH="returncode 0" #... (1 Reply)
Discussion started by: klaasjan
1 Replies

5. Shell Programming and Scripting

Problems with valid input

Hello all I am having problems with a part of my script. Basically it asks for the user to enter a new id number for them. The catches are:- * It cannot already be existing (it will check a file) * It has to be four characters * It can only be numbers * It cannot call back into the... (2 Replies)
Discussion started by: ChrisHoogie
2 Replies

6. Programming

is it valid output ?

#include <iostream> #include<stdio.h> using namespace std; class a { public: int xx; a() { cout << "in CONS a \n"; } ~a() { cout << "in DES a \n"; } }; (1 Reply)
Discussion started by: crackthehit007
1 Replies

7. Shell Programming and Scripting

': not a valid identifier

I am trying to write a bash script. I am able to do simple things like pass arguments, assign variables and echo the results. However, when I try to declare and array or anything a little more complicated I get ': not a valid identifier Here is my code so far: #!/bin/bash echo start t... (7 Replies)
Discussion started by: script123
7 Replies

8. Programming

valid code?

hey , everyone. I have a few questions about pieces of code and was wondering if someone could tell me what exactly they did or if they are even valid. bool1 && bool2 || bool3 <---in what order do these get processed? if (! isdigit(c)) <---What does this do? i = j % 3; <---what does this do?... (4 Replies)
Discussion started by: bebop1111116
4 Replies

9. Shell Programming and Scripting

Is this a valid statement?

I need an if statement that recognizes whether files fitting a certain pattern exist in the current directory. Is this syntax valid: if ; then ... fi assuming that zero="0" and star="*". Is there a better way to write it? (3 Replies)
Discussion started by: mharley
3 Replies
Login or Register to Ask a Question