Sponsored Content
Top Forums Shell Programming and Scripting Checking whether the entered text is file or not Post 302777459 by Rashid Khan on Friday 8th of March 2013 02:32:10 AM
Old 03-08-2013
let me elaborate it a bit..

the path entered by the user is supposed to be something like "$ABCD/defef/geft.txt" and i want to check if anything out of "$ABCD/defef/geft.txt" is mistyped. The script should exit.

and if, only $ABCD or defef or gef.txt is entered by the user, still script should exit.

i tried this



Code:
$Input_filename=$ARGV[0];
	
if (!-e $Input_filename $$ !-d $Input_filename) 
{
	print "the file does not exist, Please enter a valid file name";
	exit;
}


please suggest where i am mistaken...

Last edited by Rashid Khan; 03-08-2013 at 03:45 AM.. Reason: Please use code tags for data and code samples
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Repeat last entered command ?

Hi, how to do that ? I mean only print it but not execute. I'm using putty to interact with ksh. (in windows cmd up arrow does the job) thanks vilius (5 Replies)
Discussion started by: vilius
5 Replies

2. Shell Programming and Scripting

checking text file

Hello, I have the following report (report.txt) file (see attached). I would like to check the file and if the field is error, then showing error message at output. 1. In the report, 1st, 2st and 3nd line can be ignore to check 2. start to check line 4 (each field use "," to split - 1st... (1 Reply)
Discussion started by: happyv
1 Replies

3. UNIX for Dummies Questions & Answers

checking directory size in the text file

Hi All, I am new to unix scripting, please help me in completing this exercise, I have a scenario as follows, 1. i have a text file(snapshot.txt) consisting of directory names, and file size separated by comma as shown below: snapshot.txt data: ... (1 Reply)
Discussion started by: G.K.K
1 Replies

4. Shell Programming and Scripting

How to replace text in a file with text entered

I am trying to write a shell script that will allow the typing of a value, then using that value to replace data in a text file. I suspect I need sed. The format of the file is: Variable1:Value1 Variable2:Value2 The interaction would be something like: Shell Prompt: "Please enter the... (9 Replies)
Discussion started by: cleanden
9 Replies

5. Solaris

Question marks appearing instead of text entered

I have a netscape 4.79 browser for our GUI which connects to a Solaris5.8 box. During peek hours, we see question marks appearing in the screen instead of the text we enter. This results in query failure. This problem does not happen always, and is quite irritating because, we have to close the... (6 Replies)
Discussion started by: vanz
6 Replies

6. Shell Programming and Scripting

only a number can be entered no letters?

ok the user can only enter a number if a letter is entered it shouldnt be accepted This is what i have so far read -p "How many cars to enter:" cars until do read -p "Invalid number. Please re-enter:" $tags done (5 Replies)
Discussion started by: gangsta
5 Replies

7. Shell Programming and Scripting

How to accept command line argument as character or text if number is entered?

Hello Does the unix korn shell provide a function to convert number entered in command line argument to text or Character so that in next step i will convert Chr to Hex (6 Replies)
Discussion started by: aadityapatel198
6 Replies

8. Shell Programming and Scripting

How to check user entered correct file format or not?

Hi Experts, path=/db/files/ format=$1 User can enter any file format.compare the user file format with actual file format existed in the directory /db/files. User enter all characters as "A" apart from date format. example1: user will be entering the file format AAA_AA_YYYYMMDD.AAA Actual... (6 Replies)
Discussion started by: nalu
6 Replies

9. Shell Programming and Scripting

Checking and replacing first line in text file, one-liner?

Hello, I'm looking to check only the first line of a file to see if it is a format string, like # -*- coding: utf-8; mode: tcl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -\*- vim:fenc=utf-8:ft=tcl:et:sw=2:ts=2:sts=2if the first line is anything else, insert the above string. I'd... (3 Replies)
Discussion started by: f77hack
3 Replies

10. Shell Programming and Scripting

Match text to lines in a file, iterate backwards until text or text substring matches, print to file

hi all, trying this using shell/bash with sed/awk/grep I have two files, one containing one column, the other containing multiple columns (comma delimited). file1.txt abc12345 def12345 ghi54321 ... file2.txt abc1,text1,texta abc,text2,textb def123,text3,textc gh,text4,textd... (6 Replies)
Discussion started by: shogun1970
6 Replies
addgroup(8)						      System Manager's Manual						       addgroup(8)

NAME
addgroup - Adds a new group interactively SYNOPSIS
/usr/sbin/addgroup DESCRIPTION
Security Note If you have enhanced security installed on your system, you should use the dxaccounts program to add a group. See Security and the dxac- counts(8) reference page for more information. The addgroup command is an interactive program for adding new groups to the /etc/group file. The program prompts you for specific informa- tion and informs you of its activity and error conditions. Only the superuser can execute this command. The program performs the following tasks: Queries for a new group name. The default can be chosen by pressing the Return key, which will cause the program to exit without adding a new group. Enter the new group name, 8 characters or less, or Return to exit. If the new group entered already exists in the /etc/group file, the program informs you of this and cycles back to the query for a new group name. If the new group entered does not already exist, the program continues. Queries for a group number (GID) for the new group. A default GID, which is based on previously existing GID's in the /etc/group file, is displayed and can be selected by pressing the Return key. Enter a new GID or accept the default. If the new GID entered already exists in the /etc/group file, the program informs you of this and cycles back to the query for a new group number (GID). If the new GID entered does not already exist in the /etc/group file, the program uses this GID and adds the new group to the /etc/group file. At this point, the program ends. This interface has been superseded by the groupadd command-line interface, and the Account Manager (dxaccounts) graphical user interface. RESTRICTIONS
The group name is limited to eight characters. EXAMPLES
Enter a new group name or <Return> to exit: newgroup Enter a new group number [112]: FILES
Specifies the command path. Group file Lock file SEE ALSO
Commands: adduser(8), dxaccounts(8), groupadd(8), removeuser(8) Files: group(4) addgroup(8)
All times are GMT -4. The time now is 02:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy