LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 09-03-2011, 07:32 PM   #1
SANA4SPA
LQ Newbie
 
Registered: Jul 2011
Posts: 20

Rep: Reputation: Disabled
Unhappy 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.
 
Old 09-04-2011, 02:24 AM   #2
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
Hello,

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.

Kind regards,

Eric
 
Old 09-04-2011, 02:22 PM   #3
SANA4SPA
LQ Newbie
 
Registered: Jul 2011
Posts: 20

Original Poster
Rep: Reputation: Disabled
Smile Nano text editor

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."

echo "$var_Name"
echo "$var_Address"
echo "$var_Phnumber"
echo "$var_Cnumber"
echo "$var_Email"
 
Old 09-04-2011, 06:08 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,371

Rep: Reputation: 2381Reputation: 2381Reputation: 2381Reputation: 2381Reputation: 2381Reputation: 2381Reputation: 2381Reputation: 2381Reputation: 2381Reputation: 2381Reputation: 2381
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.

Here are some good bash (scripting lang) refs/tutorials; bookmark and read
http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/


Welcome to LQ
 
1 members found this post helpful.
Old 09-05-2011, 12:30 AM   #5
SANA4SPA
LQ Newbie
 
Registered: Jul 2011
Posts: 20

Original Poster
Rep: Reputation: Disabled
Redirecting script

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.
 
Old 09-05-2011, 12:44 AM   #6
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
Hello,

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.

Kind regards,

Eric
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How To: Create a Linux Script to display DNS and IP Address Information readydave Linux - Networking 7 01-06-2011 10:02 AM
[SOLVED] HTML Form that sends data entered to a bash script as variables simplified Programming 2 12-01-2009 03:35 PM
Need to create script that gives me network computer information. rahilmaknojia Programming 4 10-28-2009 01:23 PM
use script to create a data file of mulitple users RajRed Linux - Newbie 4 11-27-2007 06:05 PM
How to extract information from a large data pool with AWK script? underskinned Programming 2 11-23-2006 09:26 PM


All times are GMT -5. The time now is 07:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration