Sponsored Content
Top Forums Shell Programming and Scripting how to insert data into database by reading it from a text file?? Post 302252731 by wempy on Thursday 30th of October 2008 07:49:15 AM
Old 10-30-2008
Code:
#!/bin/bash

function processline
{
    ImiCode=$1
    CustNo=$2
    SerNo=$3
    SQL="insert into IMSERNOS (ImiCode,CustNo,SerNo) values ('$ImiCode','$CustNo','$SerNo')"
    echo $SQL
}

while read line
do
    processline $line
done

call the above like
Code:
<text.file |processfile >sql.output

which should give you nicely formatted sql statements for further processing

Last edited by wempy; 10-30-2008 at 08:52 AM.. Reason: added instructions
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to insert data in database based on text file?

Hi....can you guys help me out in this script?? Below is a text file script....called Bukom.txt and it contains these: BUKOM 20060101 2.5 2.6 2.7 2.8 2.9 2.3 2.1 BUKOM 20060102 2.4 2.5 2.6 2.7 2.7 2.6 2.4 BUKOM 20060103 2.1 ... (9 Replies)
Discussion started by: forevercalz
9 Replies

2. Shell Programming and Scripting

How to insert data into MYSql database from a text file

Hi, Need to get help from you guys about this issue. I need to insert data into MySql database from a text file which is located in other server. The text file is something look like below: Date | SubscriberNo | Call Duration 20/7/07 | 123456788 | 20 20/7/07 | 123412344 | 30 The... (4 Replies)
Discussion started by: shirleyeow
4 Replies

3. Shell Programming and Scripting

Reading data from a specific line in a text file

hello, I have got the following problem that I am hoping someone can help with please. 1. I have got the following text file (below) , the columns data are 'Test Day', 'Board', 'Betting Number'. TEXT FILE ============================================ 1 3 02-01-27-28-29-30 0 1... (1 Reply)
Discussion started by: jermaine4ever
1 Replies

4. Shell Programming and Scripting

Reading data from a specific line in a text file

Hello, I have a problem which is giving me headache for days, can some please help. Please see code and text fiel below. Please see text in red for the problem I am facing # Program gets an input x from user while read line ; do echo... (4 Replies)
Discussion started by: jermaine4ever
4 Replies

5. Shell Programming and Scripting

Reading data from DataBase and Writing to a file

Hi All, Please help me in writing data to a file in one row. In database there is a column which contains large data which does not fit in the file in one row. The column contains list of paths. I want to write these paths to a file in one row. Please find the code below writes : ... (2 Replies)
Discussion started by: rajeshorpu
2 Replies

6. Web Development

INSERT data to a Database Table from a text file

If you have a text file and if you want to Insert data to your Database Table, You can do it with these queries LOAD DATA LOCAL INFILE '/path/yourTextFile.txt' INTO TABLE yourTableName FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\n' (0 Replies)
Discussion started by: sitex
0 Replies

7. Shell Programming and Scripting

Reading and analysing data in a text file

Hi, I have below type of data in a text file in unix. Emp_Name Emp_Dept Raj 101 Amruta 100 Shilpa 100 Rohit 123 Amol 198 Rosh 101 Gaurav 198 Number of employees can be even more. Need a command or a... (2 Replies)
Discussion started by: rajneesh_kapoor
2 Replies

8. Shell Programming and Scripting

Korn shell program to parse CSV text file and insert values into Oracle database

Enclosed is comma separated text file. I need to write a korn shell program that will parse the text file and insert the values into Oracle database. I need to write the korn shell program on Red Hat Enterprise Linux server. Oracle database is 10g. (15 Replies)
Discussion started by: shellguy
15 Replies

9. Programming

Need help on Insert data to mySQL database

Hi guys, I would like to seek help on inserting data whenever the switch is on or off to my sensor mySQL database in phpMyAdmin from my control.php. I'm using Raspberry PI as my hardware and follow a few tutorials to create my own Web Control Interface, it works perfectly without insert method.... (1 Reply)
Discussion started by: aoiregion
1 Replies

10. Shell Programming and Scripting

How to read a text file line by line and insert into a database table?

I have a test file that I want to read and insert only certain lines into the the table based on a filter. 1. Rread the log file 12 Hours back Getdate() -12 Hours 2. Extract the following information on for lines that say "DUMP is complete" A. Date B. Database Name C.... (2 Replies)
Discussion started by: JolietJake
2 Replies
INDEXMAKER(1)							       mrtg							     INDEXMAKER(1)

NAME
indexmaker - Creates index files for mrtg web sites (mrtg-2.17.4) SYNOPSIS
indexmaker [options] mrtg.cfg [other.cfg ...] OPTIONS
--output=filename set output filename (default: stdout) --filter title=~regexp select targets by matching regexp against titles --filter pagetop=~regexp select targets by matching regexp against pagetop --filter name=~regexp select targets by matchin regexp against name --addhead=text insert this text between </TITLE> and </HEAD> --title=text set title of generated index file --subtitle=text add a subtitle to the generated index file --bodyopt=text set body tag options --headlevel=number use <Hnumber> at top of page (default: 1) --pagetop=text insert this text between <BODY> and <H1>...</H1> --pageend=text insert this text after the main body --pagetopend=text use this text for pagetop or pageend if undefined --nolegend do not add the Mrtg legend at the end of the page --columns=number show graphs in a table with x columns (default: 2) --perhost show graphs of the same host on a row --compact try to make a vertically more compact page --optlog log the used command line in the page (default: log) --sort=title sort graphs by title --sort=name sort graphs by their name --sort=descr sort graphs by their description --sort=original leave as is (default) --enumerate add a sequence number to the title of each graph --picfirst place pictures before text (default: text first) --width=number set width of graphs (default: not set) --height=number --sidebyside place text / pictures side by side (default: above/below) --bold use bold text (default: bold) --clicktext make the text link to the inner page (like the image) --show=day pick which graph to show in the index (default) --show=week --show=month --show=year --show=none --section=h1 h1 tag from pagetop as section heading (default) --section=title title as section headings for graphs --section=name graph name as section heading --section=descr graph description as section heading --section=portname port name entry in pagetop as section heading --sectionhost Try to prepend the host to the section heading if missing --rrdviewer=path path to rrdviewer (default: /cgi-bin/14all.cgi) --icondir=path path to icondir --prefix=path path from the location of the index.html to the graphs --headeradd=string add string to the html page header --autoprefix try to set prefix automatically --<opt>-file=file read string argument for option <opt> from file DESCRIPTION
Indexmaker can create web pages which display the status of an array of mrtg interface status pages. --output filename set output filename (default: stdout) --filter (title|pagetop|name)(=~|!~)regexp Several filters may get set. Each filter can match agains the contents of a specific section of the mrtg config file. Name refers to the bit in square brackets (option[name]: bla). Depending on the match operator chosen (=~ or !~) the match will be positive or negative. Note that some shells consider ! a special character. It may be necessary to type !~ instead. --title text Set title of generated index file (default: regexp) --bodyopt text The value of this argument gets appended to the <BODY> tag. This allows you to set document colors. By default this option is set to bgcolor="#ffffff" text="#000000" link="#000000" vlink="#000000" alink="#000000" --columns number Display graphs in a table with number columns (default: 2) --sort title|name|descr|original Sort the graphs in the page either by title, by name, by interface description, or leave them as is. --enumerate Add a sequence number to the title of each graph --width number Set width of graphs --height number Set the height of the graphs --show day|week|month|year|none Select which graph to show in the index page. You can supress images completely with --show=none. --section h1|title|name|description|portname Select what to use as the title for each graph in the page. h1 is the H1 section from pagetop, title is the graph title, name is the bit in square brackets (option[name]: bla), and descr or description is the text from the Description field of the PageTop (the Cisco description text if it's available, otherwise just the interface description). portname is the "Port Name:" from pagetop. --sectionhost Extract the hostname from the target line (this does not work if the target is a mathematial expression). Prepend the hostname (and a colon) to the section if not already present. --rrdviewer path If you have set the LogFormat: rrdtool property in the mrtg.cfg file, the index will take this into account. The only thing you must tell it is the path to your grapher cgi. (default: /cgi-bin/14all.cgi) --prefix path By default we assume that the file generated by indexmaker is stored in WorkDir. If you want to store it somewhere else, specify how to reach WorkDir from the place where the Index is stored. Note that you have to use '/' as path separator as this will be used in urls. Speaking of which, you can even enter a whole url. --autoprefix path Requires --output. Try to generate the prefix automatically by comparision of the path to the output file set with --output and the Htmldir set in the configuration files. Particulary useful when multiple configuration files are specified, with different Htmldir settings. --optlog Default is logging in the generated page the command line, suppress with --nooptlog . Useful if the commandline contains a complex --pagetop=string which could confuse simple browsers. --someoption-file filename For any someoption which takes a string as parameter you can read the string from a file by adding <-file> to the option keyword. The whole content of the file will be read and used as the string. The file must exist. AUTHOR
Tobias Oetiker <tobi@oetiker.ch> LICENSE
GNU General Public License COPYRIGHT
2000-2001 Tobias Oetiker <tobi@oetiker.ch> 2.17.4 2012-01-12 INDEXMAKER(1)
All times are GMT -4. The time now is 03:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy