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
 (381) dminister a web business
Creating A Linux Shell Script With Variable With User Input Form Prompt To Enter Data
Post Description:
Post Tags: creating, a, linux, shell, script, with, variable, with, user, input, form, prompt, to, enter, data,
This Post Has Been Viewed 2897 Times Since Thu May 03, 2007 10:09 pm Posted By linux with 2 replies
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.

Leave Your Comments     [ dejar commentarios ]
  * Name     [nombre]

  * eMail (will not be published)     [coreo electronico]

* Enter Your Reply or Comments:    [commentarios]


Add Picture To Comments         [incluir foto]
YES NO             upload
Receive Replies on my Comments (An email will be sent to you when someone replies to your comments)

     

Comments and replies About Creating A Linux Shell Script With Variable With User Input Form Prompt To Enter Data




:: 1 :: #3156 - Reply By kila On Mon May 14, 2007 7:59 am
can you pls list the command for me to prompt the user to enter name
:: 2 :: #55276 - Reply By che din On Mon May 26, 2008 1:21 pm
very good.. thanks a lot for the post