Validating user input in shell script dating elisha cuthbert

Absolute paths are required for correct mapping of directory structure.

validating user input in shell script-39

However, sometimes that's not enough and a more flexible approach is needed.

For example, you may want to ensure that the Employee ID specified for a new user is unique in the directory, verify that a user with the specified ID exists in an HR database, automatically add a digit to the username if another user with the same username exists in AD, etc.

I'm writing a bash script that requires several pieces of user input, primarily directory paths and file names.

The program will create the specified directories and files. Directory paths should only be provided in the form of /DIR/DIR/..., file paths in the form /DIR/DIR/.../filename, and file names in the form of filename.

When we requested a data dump from Human Resources (HR), we found that much of the information was incomplete. It does not mean that my boss will take me out for lunch, or even buy me flowers .

My problem is that the Help Desk people do not appear to enjoy doing this job and therefore they are sloppy. However, it does mean that I intend to do what I want today (except for the three meetings I have, and the one report I have to generate).

This modified script checks the value of str Answer; if str Answer is empty the script terminates (using Wscript. Otherwise, the script echoes the value the user typed into the dialog box: Here’s a variation which places the Input Box in a loop.

If the user clicks Cancel, the script reminds the user to enter a file name, and then displays the Input Box again.

When writing the directory path, I request the absolute path - ~/DIR/..., or $PATH/DIR/... I also want to assure the user has not added any command-line options (for example, if I run sudo, I want to assure that the user has not appended -u anywhere in their statement) to their input. I'm using an Ubuntu system, so as long as it complies with Ubuntu shell then it'll work.

However, I'm not entirely certain of the best way to sanitize their input, since directory paths and filenames may contain dashes, underscores, spaces, periods, and alphanumeric characters. Assume that only the default system packages are installed.

Here you need to specify, when the new Business Rule must be executed.

Tags: , ,