Sponsored Content
Full Discussion: Telephone Format and Check
Top Forums Shell Programming and Scripting Telephone Format and Check Post 302996499 by mrn6430 on Wednesday 26th of April 2017 06:37:54 PM
Old 04-26-2017
Did not work. Updated code below

Code:
#!/bin/bash
read -p "Enter Telephone number to check: " telno
TnDash=`echo ${telno:0:3}-${telno:4:3}-${telno:8}`
if  [ ${telno} == ${telno#*[^0-9]} ] && [ ${#telno} -eq 10 ]; then
  TN=`echo ${telno:0:3}-${telno:3:3}-${telno:6}`
else
if [ ${telno} == ${TnDash} ]; then
  TN=$telno
else
  echo "Invalid number <$telno> entered. Entry must be numeric and 10 digits separated by dashes"
fi
fi
 PORTEDIN_NUM=$TN
echo "TN Entered = $PORTEDIN_NUM"

Here is the updated code. It seems to work fine. But is it a good way to check input telephone numbers and convert?

Output test #1 :

Code:
Enter Telephone number to check: 214-800-3000
Temp = 214-800-3000
TN Entered = 214-800-3000
Check current log for this TN?[y/n]

Output test #2:

Code:
Enter Telephone number to check: 214-800-3000
TN Entered = 214-800-3000


Last edited by mrn6430; 04-26-2017 at 09:33 PM..
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

telephone working in unix

sir, i came to know that telephone exchanges use unix for the working of telephones,that is when we take our hand set in telephone we can note a dial sound,for this telephone exchanges use unix. we are going to do project using unix,i want to know wheater we can able to connect... (1 Reply)
Discussion started by: radheesh
1 Replies

2. IP Networking

all about telephone in unix

hai to all, that i came to know all telephone exchanges use unix.i want to know wheather we can connect telephones uaeing unix,if it possible means how&and also i need about more information about "telephones in unix" ... (1 Reply)
Discussion started by: radheesh
1 Replies

3. UNIX for Dummies Questions & Answers

Got connected with Modem but cannot dial Telephone no. to connect to host

Hello There, I configure my Modem as follow. Step1. # admintool & Then from Browse --> Serial Port i select tta port and Edit --> Modify From that i select Template : Modem:Dial Out Baud Rate: 9600 Ok Step 2 # tip /dev/cua/a connected (1 Reply)
Discussion started by: abidmalik
1 Replies

4. Shell Programming and Scripting

Check the format of Date

Hi, I have a date field in my input file. I just want to check if its in the format "DD-MM-YYYY". Is there any command which can achieve this? Thanks and Regards, Abhishek (2 Replies)
Discussion started by: AAA
2 Replies

5. UNIX for Dummies Questions & Answers

File format check

How to check if file is in a given format? For instance: if file records are delimeted with "|" ( pipes) and have exactly 26 fields? File is pretty big (~3 mil reccords), so not sure if I have to check all records or just head/tail records or smth. Any ideas are much much more than... (11 Replies)
Discussion started by: Leo_NN
11 Replies

6. Shell Programming and Scripting

Check input date format?

how to check input date format. for example $input_date must be in format dd.mm.gg script is execute like this: bin/script1.sh 14.12.2009 script1.sh code: #!/bin/sh input_date=$1 CMD="/app/si/test/test.sh $input_date" echo "*****" $CMD (2 Replies)
Discussion started by: waso
2 Replies

7. Homework & Coursework Questions

Telephone book script

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: Hi, here is my other assignment for the week. Create a shell script for a telephone book application. ... (7 Replies)
Discussion started by: Jagst3r21
7 Replies

8. Shell Programming and Scripting

Check Date Format And Email Out

Hello All, I have a requirement where i need to get the EXTRACT_DATE from a file and check if the date is of valid format or not and then mail it if it is not valid. Appreciate if you can help me with this. I did the following so far. awk '{for(i=1;i++<=NF;)if($i~/^EXTRACT_DATE/) print $i}'... (11 Replies)
Discussion started by: Ariean
11 Replies
script(1)							   User Commands							 script(1)

NAME
script - make record of a terminal session SYNOPSIS
script [-a] [filename] DESCRIPTION
The script utility makes a record of everything printed on your screen. The record is written to filename. If no file name is given, the record is saved in the file typescript. See WARNINGS. The script command forks and creates a sub-shell, according to the value of $SHELL, and records the text from this session. The script ends when the forked shell exits or when Control-d is typed. OPTIONS
The following option is supported: -a Appends the session record to filename, rather than overwriting it. NOTES
script places everything that appears on the screen in filename, including prompts. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ |CSI |Enabled | +-----------------------------+-----------------------------+ SEE ALSO
attributes(5) WARNINGS
script can pose a security risk when used in directories that are writable by other users (for example, /tmp), especially when run by a privileged user, that is, root. Be sure that typescript is not a link before running script. SunOS 5.11 30 Jan 2004 script(1)
All times are GMT -4. The time now is 08:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy