Creating A Linux Shell Script With Variable With User Input Form Prompt To Enter Data
creating a linux shell script with variable with user input form prompt to enter data
creating, a, linux, shell, script, with, variable, with, user, input, form, prompt, to, enter, data
Creating A Linux Shell Script With Variable With User Input Form Prompt To Enter Data
Post Description: creating a linux shell script with variable with user input form prompt to enter data
POST# 724
Posted On: Fri Feb 29, 2008 12:01 pm
linux
Topic: Creating A Linux Shell Script With Variable With User Input Form Prompt To Enter Data
creating a variable wit user input

at the command line, we can create variables explicityly by telling the shell the name of the variable and the value of assign. to do this, just follow these steps on my tutorial for you to learn how to program in linux

1. run these commands
a=1650
echo $a
the sh family of shells also creates variables with input read from the user.

2. enter this command
read xxx
No prompt is displayed but the shell is waiting for input from you

3. enter this command
Wallpaperama


4. enter this command
echo $xxx
a new variable named xx is created with a value of Wallpaperama. in this example, the shell interprets the read command as instruction to create a new variable using the argument to read as the new rabiable's name, and then to assign the varaible the value of wahtever the user types in until the next enter. the same procedure can be used tom odify the value of an exisitng variable

5. enter this command
read xxx


6. enter this
Get Free Wallpapers at Wallpaperama


7. enter this command
echo $xxx


the shell interprest the argument to the read command as the name of a variable and interprets whatever the user types until the next ENTER as the value ot assing to the variable. if the variable exits, its value is modigfied. if the variable does not exists, the shell crates it. a varable consisting of many words is acceptable. I am familiar with php, if you are also familiar in programming with php and HTML, think of read as a web form where you ask for user input, on the form itself, you use variables to declare user input. same here with the read utility in linux.
Share:
BBCODE:
HTML Code:


Mon May 14, 2007 7:59 am
1
kila
Reply #1634
can you pls list the command for me to prompt the user to enter name
Sat Mar 22, 2008 8:13 pm
2
tuiz
Reply #1788
this is great

What do you think?

* name:  

* email:  

* Please enter comments:


Receive Replies on my Comments
(An email will be sent to you when someone replies to your comments)

Add image to comments
yes no             upload