[SOLVED] How to create a data file with all entered users information. Nano script editor
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How to create a data file with all entered users information. Nano script editor
I created a script using GNU NANO 2.2.4 script editor. The script collects users information. Such as name, address etc. To my surprise it works. But, I can't figure out how to store all the different users information, that will be inputing into this script, on a data file that containing all the users information. My question is how do I create a data file that automatically stores all the differnet users information.
The editor has nothing to do with the script whatsoever, it's just a tool used to write. It would be helpful if you could post your script so that we can get an idea what commands/information you're using. Next you could point out if you want to save the data just in plain text format or in a database of some kind.
Hello Eric, Thanks for taking the time to help me out. I was under the impression that the text editors function was to create scripts? That is why I reffered to it as nano script editor. If you have the time please explain.
Here is a copy of the script that I created using GNU Nano 2.2.4. My class assignment is to create a data file with all the information entered by the user. I am a newbie, I would prefer to save it in its simpliest data file form. Thanks again.
#!/bin/bash
#Script name: Student Information
#Date created: 09/01/11
#Created by: JC Sanabria
#Purpose: Gather Student information
#Date change:
#Reason for change:
clear
echo -n "Enter your name and press [ENTER]:"
read var_Name
echo "Your name is $var_Name"
echo -n "Enter Your address and press [ENTER]:"
read var_Address
echo "Your address is $var_address"
echo -n "Enter your phone number and press [Enter]:"
read var_Phnumber
echo "Your name is var_Phnumber"
echo -n "Enter your course number and press [ENTER]:"
read var_Cnumber
echo "Your course number is $var_Cnumber"
echo -n "Enter your E-mail address and press [ENTER]:
read var_Email
echo "Your E-mail address is $var_Email"
echo "Thank you $var_name for your information. Below is the information you entered.
Please call us at 800-444-5555 if the information is incorrect."
An editor is just that; a tool to edit files. In the case of nano, its a 'plain-text' editor ie you can't edit binary files or eg OO docs etc.
See also vi/vim, gedit etc etc; Linux has a lot(!) of editors to choose from
The 'simplest' storage format would probably be a flat file eg
Code:
name:addr:phone:email
In order to use this, you need a unique identifier value for reach 'record' (line) to act as a key (index) so you only pull out one record for a request.
In your case, I'm guessing the email, in which case it should be the first field in each record.
You could use the 'cut' cmd http://linux.die.net/man/1/cut or (more powerful) awk http://www.grymoire.com/Unix/Awk.html tool.
Hello Chrism01, Thanks for taking the time to help me out. By some unusual turn of luck I came across a web site called http://www.linfo.org/echo.html. I was able to find my answer there. All I needed to do was redirect the script by adding line cat student_information>>Student_logfile. This command created a folder in my home directory called Student_logfile and placed a copy of my script inside.
As already pointed out by chrism01, there are a lot of editors available for Linux, and they are just that, tools to write. You can write a script in any of the above mentioned editors or even construct it from the console without an editor although that would limit you in fixing errors. Go through the links posted by chrism01, they'll teach you a lot. Glad you've found a solution. Have fun with Linux.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.