Disallowing certain characters from user input


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Disallowing certain characters from user input
# 1  
Old 08-09-2007
Disallowing certain characters from user input

Hey, I've create a custom useradd script, and I don't want the person creating the user to be able to put comma's in any of the input fields, because it could corrupt the /etc/passwd file.

I don't care what other characters they put in there, so is there a way I can just check all the input for comma's only, and if they are are there, just strip them out? Or replace them?

Thanks.
# 2  
Old 08-09-2007
Code:
for d in $@
do
    case $d in
    *,* )
        echo comma found
        ;;
    * )
        ;;
    esac
done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Checking the user input in perl for characters and length

My question is basically as the title says. How can I check a user inputted string is only certain characters long (for example, 3 characters long) and how do I check a user inputted string only contains certain characters (for example, it should only contain the characters 'u', 'a', 'g', and 'c')... (4 Replies)
Discussion started by: Eric1
4 Replies

2. Shell Programming and Scripting

User input and run awk using the input

I am trying to allow a user to enter in text and then store that text in a variable $gene to run in an awk command in which those values are used to run some calculations. I am getting syntax errors however, when I try. Thank you :). The awk runs great if it is a pre-defined file that is used,... (7 Replies)
Discussion started by: cmccabe
7 Replies

3. Shell Programming and Scripting

Script interacts with user , based on user input it operates

i have a script which takes input from user, if user gives either Y/y then it should continue, else it should quit by displaying user cancelled. #!/bin/sh echo " Enter your choice to continue y/Y OR n/N to quit " read A if then echo " user requested to continue " ##some commands... (7 Replies)
Discussion started by: only4satish
7 Replies

4. Shell Programming and Scripting

How to get the user input recursively until the user provides valid input

Hi, echo "Enter file name of input file list along with absolute path : " read inputFileList if then for string in `cat inputFileList` do echo $string done else echo " file does not exist" fi From the above code, if the user enters a invalid file... (1 Reply)
Discussion started by: i.srini89
1 Replies

5. Shell Programming and Scripting

Ommiting special characters as input - Help

Hey Everyone, I'm quite new to unix (hence the 0 posts!) and im trying to write a simple program that outputs what the user types in to the screen, as long as it is a letter. This part works fine, however, when a "\" is entered doesnt not display anything and moves to the next line. Is... (11 Replies)
Discussion started by: ultiron
11 Replies

6. Programming

Displaying a characters out of an input file in C++

stupid question (0 Replies)
Discussion started by: puttster
0 Replies

7. Shell Programming and Scripting

Help in preserving special characters from input file

Hi Forum. I've tried to search online for a solution but I cannot seem to find one. Hopefully, someone here can help me out. I would appreciate it. Input file abc.txt: $InputFile_Borrower=CMTSLST\EDW_COMMERCIAL_MTGE_BORROWER_dat.lst... (14 Replies)
Discussion started by: pchang
14 Replies

8. Shell Programming and Scripting

exit script if user input not four characters

#!/usr/bin/bash ###script to input four characters. wxyz echo "input first string" read instring1 echo "input second string" read instring2 ## echo "first string is:" $instring1 echo "second string is:" $instring2 ##IF instring1 or instring2 are NOT 4 characters (xxxx) , exit 1. ##how?? ... (2 Replies)
Discussion started by: ajp7701
2 Replies

9. Shell Programming and Scripting

Bourne Shell: Special characters Input Prevention

Environment: Sun UNIX Language: Bourne Shell Problem: I am writing a script that allows user to key in a directory. Example: /root/tmp. Since the user can key in anything he/she wants, I need to validate to make sure that he/she does not key in anything funny i.e.... (37 Replies)
Discussion started by: totziens
37 Replies

10. UNIX for Advanced & Expert Users

disallowing user/pass authentication in favor of a pure key system?

i finally got my key-pair system working... sort of a makeshift eToken system. however, i only want to allow this sytem for system access. i don't want to allow for the standard user/pass authentication system. right now i changed the following: # To disable tunneled clear text passwords,... (2 Replies)
Discussion started by: xyyz
2 Replies
Login or Register to Ask a Question