Sponsored Content
Top Forums Shell Programming and Scripting how to create script for this formula? Post 302314638 by ghostdog74 on Saturday 9th of May 2009 05:56:28 AM
Old 05-09-2009
if you have Python, here's an alternative
Code:
d={}
for line in open("file"):
    line=line.strip().split(" = ")    
    d[line[0]]=int(line[1])

calculation = 1 - ((d["Buffer pool data physical reads"] + 
d["Buffer pool xda physical reads"] + 
d["Buffer pool index physical reads"] + 
d["Buffer pool temporary data physical reads"] + 
d["Buffer pool temporary xda physical reads"] + 
d["Buffer pool temporary index physical reads"] ) / (d["Buffer pool data logical reads"]+
 d["Buffer pool xda logical reads"] + d["Buffer pool index logical reads"] +
 d["Buffer pool temporary data logical reads"] + 
d["Buffer pool temporary xda logical reads"] + 
d["Buffer pool temporary index logical reads"] )) * 100
print calculation

similar, it can be done with awk. split on "=" using FS, then get them into associative arrays. then do the calculation.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Quadratic Formula Program

I have a question about the program I am making. I finished it, compiled it, and there were no errors. Now when I run it, the comand prompt comes up and there are just 1's and 0's that keep looping over and over again. The program is listed before. If anyone has any suggestions I would greatly... (2 Replies)
Discussion started by: zeek
2 Replies

2. Shell Programming and Scripting

Help with formula in a script

I need some help. I been doing system admin for the last several years and gotten very rusty on scripting. I need to write a script that will take a log entry and do math using two columns of data to create a new column. I am taking the column(#2) that contains the time and the column(#5) that... (3 Replies)
Discussion started by: scottzx7rr
3 Replies

3. Solaris

formula to get the swap space on a machine

Hello there are different opinions on how to get the swap space on Solaris. some say: swap -s and the space= used + available others say swap -l (donno how they get the swap size) other say 'top' command others say using format command (in print sub-command) Could you please advise on... (1 Reply)
Discussion started by: melanie_pfefer
1 Replies

4. UNIX for Dummies Questions & Answers

Formula help

The formula below will calculate a distance in miles between 2 points in excel. Can some put it to work in unix? Lat = 43.335 Lon1 = -70.9884 Lat2 = 43.4829 Lon2 = -71.246 distance... (8 Replies)
Discussion started by: bobo
8 Replies

5. Shell Programming and Scripting

Formula to get combination… sum

Formula to get combination Lats say, I have 5 values ID Price 1 5 2 10 3 30 4 5 Resule with Possible combinations will be ID Price 1 5 2 10 3 30 4 5 1+1 10 1+2 15 1+3 35 1+4 10 (1 Reply)
Discussion started by: Amit.Sagpariya
1 Replies

6. Homework & Coursework Questions

Create script to add user and create directory

first off let me introduce myself. My name is Eric and I am new to linux, I am taking an advanced linux administration class and we are tasked with creating a script to add new users that anyone can run, has to check for the existence of a directory. if the directory does not exist then it has... (12 Replies)
Discussion started by: pbhound
12 Replies

7. Shell Programming and Scripting

Convert Formula to Value

I'm new to Perl, but I need to use it to write into an excel spreadsheet. I want to copy the values of certain cells into a new sheet in the workbook. I'm unsure of how to do this because I don't know how to copy values instead of formulas. Note: by formula I mean '=SUM(A1,A2)' and by value I... (0 Replies)
Discussion started by: AgentSmith88
0 Replies

8. Shell Programming and Scripting

formula missing in excel after using perl

Dear all, I got a template excel file which contains several worksheets. Each worksheet contains some formulas in the cells. I am using the perl script to read a CSV file and then put the data of CSV into template excel file(first worksheet) and then save it as new file name using ... (0 Replies)
Discussion started by: eldonlck
0 Replies

9. Shell Programming and Scripting

Formula missing in excel after using perl

Hi all, I use "Spreadsheet::ParseExcel::SaveParser" to - read a existing excel file with : $Parser = Spreadsheet::ParseExcel::SaveParser->new(); $HeaderFile = $Parser->Parse("XLS_FILE_ACCESS"); - modify some values in somes cell with : $worksheet->AddCell($row_target,$col_max,... (3 Replies)
Discussion started by: Yom
3 Replies

10. Shell Programming and Scripting

A strange formula

Dear Masters, Kindly need your helps for this issue.. I face a formula as a picture... the input file is A DEPT Vp Vs rho VPperVS ------------------------ ------------ ------------ ------------ 700 151.9218 121.9269 ... (11 Replies)
Discussion started by: ipatah
11 Replies
TOPEN(3F)																 TOPEN(3F)

NAME
topen, tclose, tread, twrite, trewin, tskipf, tstate - f77 tape I/O SYNOPSIS
integer function topen (tlu, devnam, label) integer tlu character*(*) devnam logical label integer function tclose (tlu) integer tlu integer function tread (tlu, buffer) integer tlu character*(*) buffer integer function twrite (tlu, buffer) integer tlu character*(*) buffer integer function trewin (tlu) integer tlu integer function tskipf (tlu, nfiles, nrecs) integer tlu, nfiles, nrecs integer function tstate (tlu, fileno, recno, errf, eoff, eotf, tcsr) integer tlu, fileno, recno, tcsr logical errf, eoff, eotf DESCRIPTION
These functions provide a simple interface between f77 and magnetic tape devices. A ``tape logical unit'', tlu, is ``topen''ed in much the same way as a normal f77 logical unit is ``open''ed. All other operations are performed via the tlu. The tlu has no relationship at all to any normal f77 logical unit. Topen associates a device name with a tlu. Tlu must be in the range 0 to 3. The logical argument label should indicate whether the tape includes a tape label. This is used by trewin below. Topen does not move the tape. The normal returned value is 0. If the value of the function is negative, an error has occured. See perror(3F) for details. Tclose closes the tape device channel and removes its association with tlu. The normal returned value is 0. A negative value indicates an error. Tread reads the next physical record from tape to buffer. Buffer must be of type character. The size of buffer should be large enough to hold the largest physical record to be read. The actual number of bytes read will be returned as the value of the function. If the value is 0, the end-of-file has been detected. A negative value indicates an error. Twrite writes a physical record to tape from buffer. The physical record length will be the size of buffer. Buffer must be of type char- acter. The number of bytes written will be returned. A value of 0 or negative indicates an error. Trewin rewinds the tape associated with tlu to the beginning of the first data file. If the tape is a labelled tape (see topen above) then the label is skipped over after rewinding. The normal returned value is 0. A negative value indicates an error. Tskipf allows the user to skip over files and/or records. First, nfiles end-of-file marks are skipped. If the current file is at EOF, this counts as 1 file to skip. (Note: This is the way to reset the EOF status for a tlu.) Next, nrecs physical records are skipped over. The normal returned value is 0. A negative value indicates an error. Finally, tstate allows the user to determine the logical state of the tape I/O channel and to see the tape drive control status register. The values of fileno and recno will be returned and indicate the current file and record number. The logical values errf, eoff, and eotf indicate an error has occurred, the current file is at EOF, or the tape has reached logical end-of-tape. End-of-tape (EOT) is indicated by an empty file, often referred to as a double EOF mark. It is not allowed to read past EOT although it is allowed to write. The value of tcsr will reflect the tape drive control status register. See ht(4) for details. FILES
/usr/lib/libU77.a SEE ALSO
ht(4), perror(3F), rewind(1) 4.2 Berkeley Distribution May 15, 1985 TOPEN(3F)
All times are GMT -4. The time now is 09:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy