Sponsored Content
Top Forums Shell Programming and Scripting Script to Gather data from logs and export to a CSV file Post 302986326 by Yagami_Sama on Wednesday 23rd of November 2016 03:34:18 PM
Old 11-23-2016
Thank you very much for the code and sorry for the delay .

Your code is light years ahead of anything I did in awk, actually my awk knowledge is limited to “print $”.

And after a few hours trying to make your code work, unfortunately I it did not run here.
Probably I did not understand you code properly, but I am getting this :


Code:
awk: billing_errors.awk:10: awk -v PAT="$PAT" -v SERV="$SERV" -F "," '
awk: billing_errors.awk:10:           ^ syntax error
awk: billing_errors.awk:10: awk -v PAT="$PAT" -v SERV="$SERV" -F "," '
awk: billing_errors.awk:10:                          ^ syntax error
awk: billing_errors.awk:10: awk -v PAT="$PAT" -v SERV="$SERV" -F "," '

removing the ‘ from here :

Code:
awk -v PAT="$PAT" -v SERV="$SERV" -F "," '

gave another errors :

Code:
awk: billing_errors.awk:10: awk -v PAT="$PAT" -v SERV="$SERV" -F ","
awk: billing_errors.awk:10:           ^ syntax error
awk: billing_errors.awk:10: awk -v PAT="$PAT" -v SERV="$SERV" -F ","
awk: billing_errors.awk:10:                          ^ syntax error
awk: billing_errors.awk:47: } cfg FS="|" /var/log/ERROR..log > /var/report/Billing_Errors_$(date +%Y%m%d).csv
awk: billing_errors.awk:47:    ^ syntax error
awk: billing_errors.awk:47: } cfg FS="|" /var/log/ERROR..log > /var/report/Billing_Errors_$(date +%Y%m%d).csv
awk: billing_errors.awk:47:                  ^ syntax error
awk: billing_errors.awk:47: } cfg FS="|" /var/log/ERROR..log > /var/report/Billing_Errors_$(date +%Y%m%d).csv
awk: billing_errors.awk:47:                             ^ syntax error
awk: billing_errors.awk:47: } cfg FS="|" /var/log/ERROR..log > /var/report/Billing_Errors_$(date +%Y%m%d).csv
awk: billing_errors.awk:47:                                                                               ^ syntax error
awk: billing_errors.awk:47: } cfg FS="|" /var/log/ERROR..log > /var/report/Billing_Errors_$(date +%Y%m%d).csv
awk: billing_errors.awk:47:                                                                       ^ syntax error
awk: billing_errors.awk:47: } cfg FS="|" /var/log/ERROR..log > /var/report/Billing_Errors_$(date +%Y%m%d).csv
awk: billing_errors.awk:47:                                                                             ^ syntax error

I created a cfg file , following your instructions and the file is in the same path as the script.

Probably I did something wrong, but could you please advise what I did wrong and where I will inform to use the cfg file and from where it will read.

Thanks again.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

unix script to export data from csv file to oracle database

Hello people, Need favour. The problem I have is that, I need to develop a unix shell script that performs recurring exports of data from a csv file to an oracle database. Basically, the csv file contains just the first name and last name will be dumped to an Unix server. The data from these... (3 Replies)
Discussion started by: vinayagan
3 Replies

2. Shell Programming and Scripting

Shell Script to Load data into the database using a .csv file and .ctl file

Since i'm new to scripting i'm findind it difficult to code a script. The script has to be an executable with 2 paramters passed to it.The Parameters are 1. The Control file name(.ctl file) 2. The Data file name(.csv file) Does anybody have an idea about it? :confused: (3 Replies)
Discussion started by: Csmani
3 Replies

3. Shell Programming and Scripting

FTP script to gather logs.

Hi, I am currently working on a FTP script which would ftp to extranet servers from intranet server and gather logs based on timestamps in archive logs and by using a wildcard character in the present logs. I have the following in place AAA="Extranet Server 1:Instance Extranet Server... (2 Replies)
Discussion started by: openspark
2 Replies

4. Web Development

script to load data from csv file

hello i want a script to load the data line by line from a csv file into a mysql table (3 Replies)
Discussion started by: srpa01red
3 Replies

5. Shell Programming and Scripting

Exporting data as a CSV file from Unix shell script

Friends...This is the first time i am trying the report generation using shell script... any suggestions are welcome. Is there a way to set the font size & color when i am exporting the data from unix shell script as a CSV file ? The following sample data is saved as a .csv file in the... (2 Replies)
Discussion started by: appu2176
2 Replies

6. Shell Programming and Scripting

Run script to export the data to ixf file in loop

Hi, I am trying to export the data to an .ixf file. I have read the table names from a .dat file and those table name should be passed to the select * from schema.TABLENAME query . I am trying the below loop while read TABLE; do db2 EXPORT TO ~/data_export/$TABLE.ixf OF IXF MESSAGES... (5 Replies)
Discussion started by: vikyalex4
5 Replies

7. UNIX for Dummies Questions & Answers

Shell script to extract data from csv file

Hi Guys, I am new to shell script.I need your help to write a shell script. I need to write a shell script to extract data from a .csv file where columns are ',' separated. The file has 7 columns having values say column 1,column 2.....column 7 as below along with their values. Name, Address,... (7 Replies)
Discussion started by: Vivekit82
7 Replies

8. Shell Programming and Scripting

Shell script to extract data from csv file

Hi everyone, I have a csv file which has data with different heading and column names as below. Static Data Ingested ,,,,,,,,,,,,Known Explained Rejections Column_1,column_2,Column_3,Column_4,,Column_6,Column_7,,% Column_8,,Column_9 ,Column_10 ,... (14 Replies)
Discussion started by: Vivekit82
14 Replies

9. Shell Programming and Scripting

Compare 2 files of csv file and match column data and create a new csv file of them

Hi, I am newbie in shell script. I need your help to solve my problem. Firstly, I have 2 files of csv and i want to compare of the contents then the output will be written in a new csv file. File1: SourceFile,DateTimeOriginal /home/intannf/foto/IMG_0713.JPG,2015:02:17 11:14:07... (8 Replies)
Discussion started by: refrain
8 Replies

10. Linux

Parsing - export html table data as .csv file?

Hi all, Is there any out there have a brilliant idea on how to export html table data as .csv or write to txt file with separated comma and also get the filename of link from every table and put one line per rows each table. Please see the attached html and PNG of what it looks like. ... (7 Replies)
Discussion started by: lxdorney
7 Replies
SCRIPT(1)						    BSD General Commands Manual 						 SCRIPT(1)

NAME
script -- make typescript of terminal session SYNOPSIS
script [-a] [-f] [-q] [-t] [file] DESCRIPTION
Script makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an assignment, as the typescript file can be printed out later with lpr(1). If the argument file is given, script saves all dialogue in file. If no file name is given, the typescript is saved in the file typescript. Options: -a Append the output to file or typescript, retaining the prior contents. -f Flush output after each write. This is nice for telecooperation: One person does `mkfifo foo; script -f foo' and another can super- vise real-time what is being done using `cat foo'. -q Be quiet. -t Output timeing data to standard error. This data contains two fields, separated by a space. The first field indicates how much time elapsed since the previous output. The second field indicates how many characters were output this time. This information can be used to replay typescripts with realistic typing and output delays. The script ends when the forked shell exits (a control-D to exit the Bourne shell (sh(1)), and exit, logout or control-d (if ignoreeof is not set) for the C-shell, csh(1)). Certain interactive commands, such as vi(1), create garbage in the typescript file. Script works best with commands that do not manipulate the screen, the results are meant to emulate a hardcopy terminal. ENVIRONMENT
The following environment variable is utilized by script: SHELL If the variable SHELL exists, the shell forked by script will be that shell. If SHELL is not set, the Bourne shell is assumed. (Most shells set this variable automatically). SEE ALSO
csh(1) (for the history mechanism), replay(1). HISTORY
The script command appeared in 3.0BSD. BUGS
Script places everything in the log file, including linefeeds and backspaces. This is not what the naive user expects. Linux July 30, 2000 Linux
All times are GMT -4. The time now is 09:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy