Sponsored Content
Top Forums Shell Programming and Scripting How to check the user input to be valid using shell script? Post 302774463 by Smiling Dragon on Saturday 2nd of March 2013 12:23:09 AM
Old 03-02-2013
If we're being picky (and I do love to be picky), you should add the sticky, setuid, and setgid flags too.
Resulting in:
^[-r][-w][-xXs][-r][-w][-xXs][-r][-w][-xXt]$
(The capital letter X is where you've got a forth byte set but no execute).
This User Gave Thanks to Smiling Dragon For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to check for a valid numeric input

Hi Folks, I'm using bash script. I would like to check whether input is a number or not.(Only positive numbers).. if space or non numeric is entered, it should say "invalid input". pls help.. thanks in adv. Br/// Vijay. (1 Reply)
Discussion started by: Vijayakumarpc
1 Replies

2. Shell Programming and Scripting

SQL PLUS Command 'ACCEPT' is not waiting for user input with sh shell script

Dear All, The sqlplus 'Accept' command is not waiting for user input when I include the command within a shell script. Note: The 'Accept' command is working fine if I execute it in a SQLPLUS Prompt. Please fins the below sample script which i tried. SCRIPT: -------- #!... (4 Replies)
Discussion started by: little_wonder
4 Replies

3. Shell Programming and Scripting

User Input Shell Script

Hello I am trying to create a user input shell scipt. The objective is user should enter the circuit number and the input is saved in a log file. If the user does not enter anything then the question should prompt it until the circuit no. is entered. Can any one please correct the code below.... (3 Replies)
Discussion started by: sureshcisco
3 Replies

4. Shell Programming and Scripting

shell script to take input from a text file and perform check on each servers and copy files

HI all, I want to script where all the server names will be in a text file like server1 server2 server3 . and the script should take servernames from a text file and perform copy of files if the files are not present on those servers.after which it should take next servername till the end of... (0 Replies)
Discussion started by: joseph.dmello
0 Replies

5. Homework & Coursework Questions

Bash shell - Check if value is valid directory.

1. The problem statement, all variables and given/known data: The script usage will be as follows: library.third source_directory - Your script will display an appropriate error message and exit with status 3 if no parameters are given - Your script will display an appropriate error... (2 Replies)
Discussion started by: netmaster
2 Replies

6. 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

7. Shell Programming and Scripting

create an array which can store the strings from the user input in shell script

I want to create an array which can store the strings from the user input in shell script . example :- I want to store the 5 fruits name in a single array which the user provides . (1 Reply)
Discussion started by: Pkast
1 Replies

8. Shell Programming and Scripting

Shell script to accept user input on the fly

I want a shell script that accepts user input simultaneously when performing other tasks. Example: A shell script should echo some messages on the console and when the user presses some keys it should respond to that action. say, when user presses the key A - more information should be printed... (2 Replies)
Discussion started by: Arun_Linux
2 Replies

9. Shell Programming and Scripting

Need a script to check if an argument is valid shell variable

I need a script that should print 'yes' if the argument is a valid shell variable name else 'No' if it is not a valid shell variable. A valid one begins with an alphabet or percentage (%) character and is followed by zero or more alphanumberic or percentage (%) characters. For example: $... (6 Replies)
Discussion started by: pingiliarjun
6 Replies

10. Shell Programming and Scripting

Recording user input from interactive shell script

Hello, I want to start out by saying that I am fairly new to scripting and am looking for someone that can point me in the right direction. Basically what I need is a way to run a interactive script that will prompt users with questions weather that be yes/no or a specific answer.. I want to be... (3 Replies)
Discussion started by: shoutcast
3 Replies
SCRIPT(1)						    BSD General Commands Manual 						 SCRIPT(1)

NAME
script -- make typescript of terminal session SYNOPSIS
script [-adfkpqr] [-F pipe] [-t time] [file [command ...]] DESCRIPTION
The script utility makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an assignment, as the typescript file can be printed out later with lpr(1). If the argument file is given, script saves all dialogue in file. If no file name is given, the typescript is saved in the file typescript. If the argument command is given, script will run the specified command with an optional argument vector instead of an interactive shell. The following options are available: -a Append the output to file or typescript, retaining the prior contents. -d When playing back a session with the -p flag, do not sleep between records when playing back a timestamped session. -F pipe Immediately flush output after each write. This will allow a user to create a named pipe using mkfifo(1) and another user may watch the live session using a utility like cat(1). -f Create file.filemon or typescript.filemon using filemon(4). -k Log keys sent to the program as well as output. -p Play back a session recorded with the -r flag in real time. -q Run in quiet mode, omit the start, stop and command status messages. -r Record a session with input, output, and timestamping. -t time Specify the interval at which the script output file will be flushed to disk, in seconds. A value of 0 causes script to flush after every character I/O event. The default interval is 30 seconds. The script ends when the forked shell (or command) exits (a control-D to exit the Bourne shell (sh(1)), and exit, logout or control-D (if ignoreeof is not set) for the C-shell, csh(1)). Certain interactive commands, such as vi(1), create garbage in the typescript file. The script utility works best with commands that do not manipulate the screen. The results are meant to emulate a hardcopy terminal, not an addressable one. ENVIRONMENT
The following environment variables are utilized by script: SCRIPT The SCRIPT environment variable is added to the sub-shell. If SCRIPT already existed in the users environment, its value is overwrit- ten within the sub-shell. The value of SCRIPT is the name of the typescript file. SHELL If the variable SHELL exists, the shell forked by script will be that shell. If SHELL is not set, the Bourne shell is assumed. (Most shells set this variable automatically). SEE ALSO
csh(1), filemon(4) (for the history mechanism). HISTORY
The script command appeared in 3.0BSD. The -d, -p and -r options first appeared in NetBSD 2.0 and were ported to FreeBSD 9.2. BUGS
The script utility places everything in the log file, including linefeeds and backspaces. This is not what the naive user expects. It is not possible to specify a command without also naming the script file because of argument parsing compatibility issues. When running in -k mode, echo cancelling is far from ideal. The slave terminal mode is checked for ECHO mode to check when to avoid manual echo logging. This does not work when the terminal is in a raw mode where the program being run is doing manual echo. If script reads zero bytes from the terminal, it switches to a mode when it only attempts to read once a second until there is data to read. This prevents script from spinning on zero-byte reads, but might cause a 1-second delay in processing of user input. BSD
December 4, 2013 BSD
All times are GMT -4. The time now is 04:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy