Prompt user for info


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Prompt user for info
# 1  
Old 12-09-2010
Prompt user for info

Please forgive this newbie question. I have a need to create a script that asks a user for information. Something like:

What is the name: $NAME_TYPED_HERE

Is $NAME_TYPED_HERE Correct ? YES (NO would go back to -What is the Name-)

mkdir then goes on behind the scene and makes folder called $NAME_TYPED_HERE

Could someone point me in the right direction. I am familiar with shell scripting but have not really had to use variables. I am on Solaris.

Thanks
# 2  
Old 12-09-2010
Code:
while :
do
     echo "Enter your directory name :"
     read dn
     echo "Your directory will be $dn , do you confirme y/n?"
     read ans
     case $ans in
          y) mkdir $dn && break ;;
          n) echo "$dn will not be created, try again" ;;
          *) echo "Wrong answer"; exit 1 ;;
     esac
done

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

User prompt for perl

perl -aF/\\t/ -lne 'BEGIN{%m=map{chomp;s/\cM|\cJ//g;$p=join("\t",(split/\t/));($p,$_)} <>;$m{"#CHROM\tINFO"}=$m{"Chr\tSegment Position"}};/SEGPOS=(\d+)/ || /\t(INFO)\t/ or next;$p=$F."\t".$1;exists $m{$p} and print join("\t",$_,$m{$p})' 12345_Marfan20_Output_Mutation_Report.txt <... (3 Replies)
Discussion started by: cmccabe
3 Replies

2. UNIX for Dummies Questions & Answers

Linux user prompt

Hi, I cant seem to get this right. Lets say I have root privileges and I wanted: a ) edit the user prompt to show "linux1234$" whenever they log-in. also b ) Show a message for users upon logging in. I know a) has something to do with editing PS1. but how to only apply the change for users?... (1 Reply)
Discussion started by: Azi
1 Replies

3. Linux

Could not get info for user -- wbinfo

Hi Experts, I'm not able to get the info of user's from wbinfo. But I'm able to join the user in domain(net rpc join -U username....). I have deleted the *.tdb file under /var/lib/smaba and set winbind cache time = 40 and restarted the winbind, Still it not works.. And not able to... (0 Replies)
Discussion started by: eeegopikannan
0 Replies

4. Shell Programming and Scripting

Update LDIF User info based on Test User Certs ID's

Hi I need help.......... I have an Sun One Directory server LDIF file with 5000 user entries, I need to change the data to match Test ID's, so I can run a perf test. I'm way out of my league as I have not done any scripting for 10 years. There are four entries for each user in the file... (3 Replies)
Discussion started by: Macdaddy99
3 Replies

5. UNIX for Dummies Questions & Answers

change user> to user@host> ssh prompt

Hi, I was wondering how to change the prompt for my ssh login. At the moment it is like user> while I'd like it to be as user@host> It is in the .bash_profile or .ssh ??? Thanks (2 Replies)
Discussion started by: pmasterkim
2 Replies

6. Shell Programming and Scripting

Help with a user prompt

Hi, I am attempting to write a BASH shell script that will prompt users for responses before accomplishing some tasks. Due to the top-to-bottom nature of shell scripts, asking users questions in sequence is quite easy. However, I am interested in allowing users to go back to and re-answer... (1 Reply)
Discussion started by: msb65
1 Replies

7. UNIX for Dummies Questions & Answers

User Info

How could I get the details about a user logged in a Unix system? ( WHat tasks did he perform or if he had changed any file or not)? Please answer my question. (1 Reply)
Discussion started by: s_dhar
1 Replies

8. UNIX for Dummies Questions & Answers

getting user info on a file

I know this is prob a simple question but anyway here goes. I want to find out the owner of a certain file. I also want to find out what permissions that owner has. Is their any command that is similair to file in that it can tell men this specfic information about a file the way file tells you... (1 Reply)
Discussion started by: Quesa
1 Replies

9. UNIX for Advanced & Expert Users

User log in info

Hi, I am using SunOS and HP-UX. I am trying to removed user that has not been using the system for a period of time. Is there anyway to find out how long since the last time the user logged on. I know there is command "last" that read from the file /etc/wtmp that hold some of information. ... (1 Reply)
Discussion started by: vtran4270
1 Replies
Login or Register to Ask a Question