Sponsored Content
Top Forums Shell Programming and Scripting major help needed phone dir script need advancing Post 302348750 by zappedback on Saturday 29th of August 2009 01:08:22 PM
Old 08-29-2009
major help needed phone dir script need advancing

dam i stuck i am trying to write a script that is a basic phone book so i can enter a name or number or both into the scripts and by

using positional paramiters the script will check if the name has a number in it and warn that numbers are not allowed with names, if i

enter a number then the script will check to see if the number has 8 numbers and the first number is not a zero.

this is a example of how i want to run my script
names entered here are for example only

./dir.sh "john smith"
./dir.sh "john smith" 12345678
./dir.sh 87654763
./dir.sh adam

so this is NOT allowed in my script

./dir.sh "john smith1"
./dir.sh 01234567

so as you can see i need to tell the positional paramiters how to filter the user input using $1 $2 any help with this would be very

apreciated.



My broken code so far:


#! /bin/sh

clear

# This code checks to make sure the book.txt file is there and can be read/writen to
if [ -f book.txt ] && [ -r book.txt ] && [ -w book.txt ]

then
echo "\n"
else
echo "book.txt file does not exist script exiting"; exit
fi




# Here is the code to check the name entered is only letters no numbers
name= $1
case $1 in
*) [ ! a-zA-Z ];; *) echo "INVALID NAME";;
*) echo OK ;;
esac




# This code checks to make sure only 8 numbers are used and that the first number is not a zero
case $2 in
[0-9]*) if [ `echo $2 | wc -c` -ne 9 -o `echo $2 | cut -c1` -eq 0 ]; then
echo "No zero as the first number and length must be 8 numbers long"
else
echo yes
fi
;;
*)
echo usage
;;
esac
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

script to go to a different dir to run a commandline prompt in that dir

Hi, I need to know how I'll be able to write a script that can goto a different dir where I don't have access to read,write and execute and also to run a commandline prompt in that dir with one file whose path has to be specified in that command. Will I be able to do this? Any ideas or... (2 Replies)
Discussion started by: ann_124
2 Replies

2. UNIX for Dummies Questions & Answers

Major Help Urgently Needed!!!!

Right deleted Linux partition usig windows then went to format c:\ but had to exit window now pc ONLY boots into GNU Grub. Does anyone know how to format the hard drive now????? (3 Replies)
Discussion started by: billett05
3 Replies

3. Shell Programming and Scripting

a script to clone a dir tree, & overwrite the dir struct elsewhere?

hi all, i'm looking for a bash or tcsh script that will clone an empty dir tree 'over' another tree ... specifically, i'd like to: (1) specify a src directory (2) list the directory tree/hiearchy beneath that src dir, w/o files -- just the dirs (3) clone that same, empty dir hierarchy to... (2 Replies)
Discussion started by: OpenMacNews
2 Replies

4. Shell Programming and Scripting

Phone Shell Script !?

could you please find a solution for this script (called phone) that creates a simple telephone list (create an empty file called “phonlist” in home directory) . Each line in this file consist of two fields name and the phone number, the script should do the following: When user types the... (1 Reply)
Discussion started by: anything
1 Replies

5. Shell Programming and Scripting

Help me to create a phone book using shell script

Hi guys... can any one help me out with creating a phone book: CP5290 Assignment: Phonebook Due 4 pm Friday 25th September 2009 Weight: 15% You are to implement a Phonebook using Shell scripting and UNIX command line utilities and commands. Some documentation will also be... (1 Reply)
Discussion started by: monster11209
1 Replies

6. Shell Programming and Scripting

A script to find dir, delete files in, and then del dir?

Hello!! I have directories from 2008, with files in them. I want to create a script that will find the directoried from 2008 (example directory: drwxr-xr-x 2 isplan users 1024 Nov 21 2008 FILES_112108), delete the files within those directories and then delete the directories... (3 Replies)
Discussion started by: bigben1220
3 Replies

7. Shell Programming and Scripting

Perl script :- Phone number validation

Hi All, I am doing a perl script validation for Phone numbers. The normal phone number format is 01-32145. I need to do two validations for the phone number 1) A valid phone number can have at least two digits as prefix and at least five digits as postfix. e.g. 01-01011 2) A... (5 Replies)
Discussion started by: subin_bala
5 Replies

8. Shell Programming and Scripting

Need a script to move the files from one dir to other other dir

Need a script to move the files from one dir to other dir and at the same time it has to read the log in the source dir. Please help me ASAP. (4 Replies)
Discussion started by: viswanathkishor
4 Replies

9. Shell Programming and Scripting

Script to move all files in a dir into a certain dir

Hello all, I'm very new to shell scripting and need quite urgently to do this thing for my student job. I have a directory called "vectors" with a bunch of files all named ".vector". also i have for each of those files a directory with the name . I now want to move each of those *.vector files... (2 Replies)
Discussion started by: sherresh
2 Replies
BITPIM(1)						      General Commands Manual							 BITPIM(1)

NAME
bitpim - utility to communicate with many CDMA phones SYNOPSIS
bitpim [ -c file | -d dir ] [ -f model ] [ -p device ] [ bitfling ] [ debug ] [ cli-command ] DESCRIPTION
This manual page documents briefly the bitpim command. BitPim allows you to view and manipulate data on many phones from LG, Samsung, Sanyo, and other manufacturers that use Qualcomm CDMA chips. Depending on your phone model, you may be able to access the phone book, the calendar, wallpapers, ring tones, and the filesystem. OPTIONS
A summary of options is included below. -c file Read configuration from file. -d dir Read configuration from dir/.bitpim. -f model Assume a phone type of model rather than what the configuration file specifies. Particularly useful in CLI mode. -p device Communicate with the phone via the device ("port") device. bitfling Run as bitfling(1). debug Print debugging information to standard output and standard error. cli-command Interact with the phone's filesystem via a command-line interface. The command must be a single (quoted) argument, and can take any of the following forms: cli Bring up an interactive shell, allowing all of the below commands as well as a few others (cd dir, cdu, exit, and pwd or equivalently cwd). cp src [...] destdir Copy files to, from, or within the phone. ll dir [...] Print a detailed listing of the specified phone directory or directories. ls dir [...] Print a brief listing of the specified phone directory or directories. mkdir dir [...] Create a directory on the phone. rm file [...] Remove one or more files from the phone. rmdir dir [...] Remove one or more directories, which must already be empty, from the phone. Please note that none of these commands accepts wildcards. To indicate that an argument denotes a file or directory on the phone, you can prefix it with phone:; this is mainly relevant for cp, which performs phone-to-PC copies unless otherwise directed. FILES
$HOME/.bitpim-files/.bitpim The default configuration file. SEE ALSO
bitfling(1), http://www.bitpim.org/. AUTHOR
bitpim was primarily written by Roger Binns <rogerb@rogerbinns.com>. This manual page was written by Aaron M. Ucko <ucko@debian.org>, for the Debian project (but may be used by others). 2007-12-12 BITPIM(1)
All times are GMT -4. The time now is 04:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy