Unix/Linux Go Back    


Programming Post questions about C, C++, Java, SQL, and other programming languages here.

Shell script - to see if any change from last csv

Programming


Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 02-16-2017
robertkwild robertkwild is offline
Registered User
 
Join Date: Apr 2016
Last Activity: 12 April 2017, 3:55 PM EDT
Posts: 54
Thanks: 5
Thanked 3 Times in 2 Posts
Shell script - to see if any change from last csv

hi all,

i attach a csv file of what im trying to explain

basically i get iMacro (like an excel macro that you can record and play back recordings but its for web browsers) to download csv reports of the printer(s)

when you open the csv report it contains certain cells -

D7 - black level 1 - 44
E7 - colour level 2 - 41
F7 - colour level 3 - 58

i have bat file to run the iMacros every day to monitor how much clients/customers are printing so this figure will go up or stay the same

i want to know if it can be possible to create a shell script to work out from the 2 reports the differences?

many thanks,

rob
Attached Files
File Type: zip 16-02-2017_XSAreport.zip (847 Bytes, 5 views)
Sponsored Links
    #2  
Old Unix and Linux 02-16-2017
RudiC RudiC is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 29 April 2017, 11:25 AM EDT
Location: Aachen, Germany
Posts: 10,705
Thanks: 264
Thanked 3,285 Times in 3,026 Posts
There's only one report in that file. You mean: compare cells D7, E7, and F7 in today's report with the same cells in yesterday's?
You mention a .bat file which is a M$ windows batch script? Do you want the new script to run in a wndows environment, or on a veritable *nix host?
Sponsored Links
    #3  
Old Unix and Linux 02-16-2017
robertkwild robertkwild is offline
Registered User
 
Join Date: Apr 2016
Last Activity: 12 April 2017, 3:55 PM EDT
Posts: 54
Thanks: 5
Thanked 3 Times in 2 Posts
yes the batch script i have made runs on windows (same machine i run the iMacros program on)

it would be nice to run it on the same machine ie windows but im more familiar with shell scripting now so would prefer linux

i have made a batch script that runs iMacros every night and produces a new csv report so i just want to cross reference todays one with yesterdays one or todays one with 7 days ago

the rows are always different ie the rows are the room names ie that file i gave you said "carnaby 3" or "bookings" but what stays the same is the colums
    #4  
Old Unix and Linux 02-16-2017
RudiC RudiC is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 29 April 2017, 11:25 AM EDT
Location: Aachen, Germany
Posts: 10,705
Thanks: 264
Thanked 3,285 Times in 3,026 Posts
Not clear. Please rephrase the entire specification giving the exact logics to apply, the OS to run it under, and the preferred tools to deploy.
Sponsored Links
    #5  
Old Unix and Linux 02-17-2017
robertkwild robertkwild is offline
Registered User
 
Join Date: Apr 2016
Last Activity: 12 April 2017, 3:55 PM EDT
Posts: 54
Thanks: 5
Thanked 3 Times in 2 Posts
i will give you the code to the Imacros -


Code:
VERSION BUILD=10.3.27.5830
TAB T=1
URL GOTO=http://172.17.4.52/
FRAME NAME=theHeader
TAG POS=1 TYPE=A ATTR=TXT:Properties
FRAME NAME=theBottom
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/userpost/xerox.set ATTR=NAME:webUsername CONTENT=admin
SET !ENCRYPTION NO
TAG POS=1 TYPE=INPUT:PASSWORD FORM=ACTION:/userpost/xerox.set ATTR=NAME:webPassword CONTENT=password
TAG POS=1 TYPE=BUTTON:SUBMIT FORM=ACTION:/userpost/xerox.set ATTR=TXT:Login
FRAME NAME=theTree
TAG POS=1 TYPE=A ATTR=TXT:Login/<SP>Permissions/<SP>Accounting
TAG POS=1 TYPE=A ATTR=TXT:Accounting<SP>Methods
FRAME NAME=theContent
TAG POS=1 TYPE=BUTTON ATTR=TXT:Report<SP>and<SP>Reset
TAG POS=2 TYPE=INPUT:RADIO FORM=ACTION:# ATTR=NAME:frmusageReportList CONTENT=YES
ONDOWNLOAD FOLDER=Z:\printers\accounts\ FILE={{!NOW:dd-mm-yyyy}}_XSAreport.csv WAIT=YES
TAG POS=1 TYPE=BUTTON FORM=ACTION:# ATTR=TXT:Download<SP>Report<SP>(.csv)
WAIT SECONDS=10

and i run this batch script everynight using task scheduler -


Code:
"C:\Program Files\Ipswitch\iMacros\iMacros.Sidebar.exe" -macro "C:\ie_imacro\iMacros\Macros\accounts.iim"

so what the batch file does is that it runs the imacro program for the accounts printer

it saves the file in the location "Z:\printers\accounts\ FILE={{!NOW:dd-mm-yyyy}}_XSAreport.csv"

it runs 24/7 and produces csv reports for all the days (the attachment i showed you)

all this runs on a windows 7 machine

now i want to extract the csv data in specific columns D, E, F and the whole of column A as column A is showing the clients/customers names

am i making any sense?

sorry if im not

---------- Post updated at 11:20 AM ---------- Previous update was at 10:42 AM ----------

im getting somewhere -


Code:
awk -F"," '{print $1,$4,$5,$6}' 16-02-2017_XSAreport.csv

---------- Post updated 02-17-17 at 04:20 AM ---------- Previous update was 02-16-17 at 11:20 AM ----------


Code:
awk -F',' 'NR>3 {print $1,$4,$5,$6}' 16-02-2017_XSAreport.csv

Sponsored Links
    #6  
Old Unix and Linux 02-18-2017
Scrutinizer's Unix or Linux Image
Scrutinizer Scrutinizer is offline Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 30 April 2017, 2:46 AM EDT
Location: Amsterdam
Posts: 11,410
Thanks: 489
Thanked 3,280 Times in 2,895 Posts
Try something like:


Code:
awk '
  {
    s=$1
    for(i=4; i<=6; i++) {
      if (FNR==NR) 
        A[NR,i]=$i
      else
        s=s OFS A[FNR,i]-$i
    }
  }
  NR>FNR && FNR>1 {
    print s
  }
' FS=, OFS=, 15-02-2017_XSAreport.csv 16-02-2017_XSAreport.csv

The Following User Says Thank You to Scrutinizer For This Useful Post:
robertkwild (02-21-2017)
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Shell script to change the ip dinesh17 Shell Programming and Scripting 1 03-16-2012 07:36 AM
Parameter change in shell script damodarreddys UNIX for Dummies Questions & Answers 3 12-05-2011 06:56 AM
Shell Script to change a user password using script indrajit_renu Shell Programming and Scripting 3 11-23-2010 06:17 AM
Change the Windows Batch script to UNIX shell script. tomailraj Shell Programming and Scripting 5 08-27-2009 11:44 AM
Shell script to change a value rijeshpp Shell Programming and Scripting 3 05-19-2009 12:18 PM



All times are GMT -4. The time now is 03:16 AM.