08-11-2005
validate input from user for file name
Hello,
This may have been addressed already somewhere, however I am looking for the easiest/shortest way to validate a response from a user for a file name.
The file name should not have any of the following characters
~`!@#$%^&*()_-+={[}]|\:;"'<,>.?/
Further the response should not have any control characters or non printable characters.
Please advise which utility to use for this purpose. I am kind of leaning toward either a tr or sed or grep command. Please advise. Thanks.
Jerardfjay
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi
How would i validate value of a variable whether it is number,date or string
Thanks in advance
Sas (5 Replies)
Discussion started by: SasDutta
5 Replies
2. Shell Programming and Scripting
the user inputs names that have to be inside square brackets
I want to check if the user puts the brackets and if not ask him to re-enter the names (9 Replies)
Discussion started by: DDoS
9 Replies
3. UNIX for Dummies Questions & Answers
Hey, im trying to validate a user input and need some help. The input needs to be just a single letter. Im using a case to so this eg:
read answer
case $answer in
*) echo "OK"
;;
*) echo "This is a number"
read answer
;;
*) echo... (2 Replies)
Discussion started by: 602chrislys
2 Replies
4. Shell Programming and Scripting
Hi,
This will most likely be a simple answer.
Currently I have a situation where my script will be sent various options:
-o1 -o2 -oe3@somthing.com
Now, if I want to run a certain command based on the option I am sent, I am doing the following.
for o in $(echo $options)
do
if
... (3 Replies)
Discussion started by: stuaz
3 Replies
5. Shell Programming and Scripting
Hi,
I wonder how I can know if the input parameters to the script are numbers or text
Thanks (11 Replies)
Discussion started by: Gengis-Kahn
11 Replies
6. Shell Programming and Scripting
I'm trying to only read price (FLOAT (i.e 1.10, 3.14, etc etc))
If the input is just an integer, I will add a .00 behind. (i.e 3 becomes 3.00 , 20 becomes 20.00)
If the input is without 2 decimal places, I'll add a 0. (i.e 3.1 becomes 3.10)
I tried using the below code, it works but I don't... (6 Replies)
Discussion started by: andylbh
6 Replies
7. Shell Programming and Scripting
The scope of the shell/perl script is to read the input text file. Validate the expiry date of each certificate and send the mail to the user. The user takes action to add the new certificate to the storage file and user owns the responsibility to update the input text file with the new certificate... (5 Replies)
Discussion started by: casmo
5 Replies
8. Shell Programming and Scripting
I'm writing a bash shell script to 'help' me post to susepaste (I can NEVER remember the time options).
Here's the code:
#!/bin/bash
##########
#
# Project : personal script.
# Started : Wed Aug 03, 2011
# Author : Habitual
# Description : susepaste c-li script with user... (5 Replies)
Discussion started by: Habitual
5 Replies
9. Shell Programming and Scripting
hi all,
i have a script that need user input provide all variables that needed to complete a job.
this is my current script:
echo "type file source and it full path :"
read INPUTFILE
if || ;
then
echo "ERROR: you didn't enter a file source or file source is not... (2 Replies)
Discussion started by: makan
2 Replies
10. Shell Programming and Scripting
$Input_filename=$ARGV;
if (!-d $Input_filename && ! -e $Input_filename)
{
print "USAGE: Please enter '$ABCD/def/dsed.txt' as an arguement \n";
exit;
}
1. Input Is suppose to be something like "$ABCD/def/dsed.txt".
if the input is wrong the script should throw an ERROR message.... (2 Replies)
Discussion started by: Rashid Khan
2 Replies
LEARN ABOUT FREEBSD
strings
STRINGS(1) BSD General Commands Manual STRINGS(1)
NAME
strings -- print the strings of printable characters in files
SYNOPSIS
strings [-a | --all] [-e encoding | --encoding=encoding] [-f | --print-file-name] [-h | --help] [-n number | --bytes=number | -number] [-o]
[-t radix | --radix=radix] [-v | --version] [file ...]
DESCRIPTION
For each file specified, the strings utility prints contiguous sequences of printable characters that are at least n characters long and are
followed by an unprintable character. The default value of n is 4. By default, the strings utility only scans the initialized and loaded
sections of ELF objects; for other file types, the entire file is scanned. The strings utility is mainly used for determining the contents
of non-text files.
If no file name is specified as an argument, standard input is read.
The following options are available:
-a | --all
For ELF objects, scan the entire file for printable strings.
-e encoding | --encoding=encoding
Select the character encoding to be used while searching for strings. Valid values for argument encoding are:
s for single 7-bit-byte characters (ASCII, ISO 8859).
S for single 8-bit-byte characters.
l for 16-bit little-endian.
b for 16-bit big-endian.
L for 32-bit little-endian.
B for 32-bit big-endian.
The default is to assume that characters are encoded using a single 7-bit byte.
-f | --print-file-name
Print the name of the file before each string.
-h | --help
Print a usage summary and exit.
-n number | --bytes=number | -number
Print the contiguous character sequence of at least number characters long, instead of the default of 4 characters.
-o Equivalent to specifying -t o.
-t radix | --radix=radix
Print the offset from the start of the file before each string using the specified radix. Valid values for argument radix are:
d for decimal
o for octal
x for hexadecimal
-v | --version
Display a version identifier and exit.
EXIT STATUS
The strings utility exits 0 on success, and >0 if an error occurs.
EXAMPLES
To display strings in /bin/ls use:
$ strings /bin/ls
To display strings in all sections of /bin/ln use:
$ strings -a /bin/ln
To display strings in all sections of /bin/cat prefixed with the filename and the offset within the file use:
$ strings -a -f -t x /bin/cat
SEE ALSO
ar(1), nm(1), objdump(1), ranlib, readelf(1), size(1)
HISTORY
The first FreeBSD strings utility appeared in FreeBSD v3. It was later discontinued in FreeBSD v5, when i386-only a.out format was dropped in
favor of ELF.
AUTHORS
The strings utility was re-written by S.Sam Arun Raj <samarunraj@gmail.com>. This manual page was written by S.Sam Arun Raj
<samarunraj@gmail.com>.
BSD
December 19, 2011 BSD