Sponsored Content
Top Forums Shell Programming and Scripting passing variable from bash to perl from bash script Post 302201544 by arsidh on Monday 2nd of June 2008 10:59:49 AM
Old 06-02-2008
CPU & Memory passing variable from bash to perl from bash script

Hi Guys,
Now have some other problem with Perl script.
The solution which is given is working perfectly , if the dates are with in same month.If i give dates like this

export FROM_DATE=04/05/2008
export TO_DATE=02/06/2008
perl -ne 'print if ( $_ >= "'$FROM_DATE'" && $_ <= "'$TO_DATE'" )' monitor.audit >$FINAL_DATA
Then nothing is comming in the log file.

monitor.audit
==================

06/05/2008-10:24: orasdfprd01:DATABASE:gecolfdsafprd :1
06/05/2008-10:24: cisdsfsdmarsp010:DATABASE:mafdsrp :1
06/05/2008-10:24: sdfsdacismarsfp011:DATABASE:dxfdslp :1
06/05/2008-10:24: alpfdscisfdfspdb053:DATABASE:mbdsfsop :1
12/05/2008-10:24: cisfsdfmasdfdsfrsp020:APPLCATION :1
12/05/2008-10:24: cisdsfdsfmarsp021:APPLCATION :1
12/05/2008-10:24: alpcsdfdsfispapp054:DISCOVER :0
12/05/2008-10:24: alpcsdfdsispapp055:DISCOVER :1
12/05/2008-10:39: orapsdafdsafrd01:DISK : 456
12/05/2008-10:39: cismdsafsdaarsp010:DISK : 77
12/05/2008-10:39: cisfsdafdsamarsp011:DISK : 138
20/05/2008-10:39: cismsdafsdaarsp020:DISK: 28
20/05/2008-10:39: cismfsdfsdarsp021:DISK: 28
20/05/2008-10:39: alpcsdfdsispapp054:DISK: 190
20/05/2008-10:39: alpcifasfsdaspapp055:DISK: 190
20/05/2008-10:39: alpcfsdafsdaispdb053:DISK: 309
02/06/2008-10:39: orasdfdsprd01:LOAD: 1.05
02/06/2008-10:39: cisdsfdsmarsp010:LOAD:2.86
02/06/2008-10:39: cissdafdsmarsp011:LOAD:0.43
02/06/2008-10:39: cismasadfsdrsp020:LOAD:0.12
02/06/2008-10:39: cismarsdfdssp021:LOAD:0.08
02/06/2008-10:39: alpcisdsfdsapapp054:LOAD:0.44

================================

Please can any one suggest on this .
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing options to a bash script

I'm just not sure where to start looking into this. I want to be able to create switches for my script. Back in the day I'd make my scripts interactive...you know: echo "what report do you want" echo "A)boxes with errors" echo "B)boxes with more than 5 errors" echo "C)Service groups that have... (3 Replies)
Discussion started by: DeCoTwc
3 Replies

2. Shell Programming and Scripting

Passing a MySql password from bash script

Hi all, I am running this script on Mandrakelinux release 10.1, 2.6.8.1-12mdksmp #1 SMP I have also installed 'expect' separately. I have created an Rsync script, but before any Rsync command does run, a MySql dump must be done first, and I am battling a bit to pass the MySql password from... (2 Replies)
Discussion started by: codenjanod
2 Replies

3. Shell Programming and Scripting

Passing Bash variable to javascript

How do I pass a bash variable to a javascript? I've tried #!/bin/bash echo "Content-type: text/html" echo "" echo "<html>" echo "<head>" counter=0 echo '<script> window.parent.document.forms.counter.value = "$counter"; </script>' I have an iframe script which I am trying to pass a... (3 Replies)
Discussion started by: numele
3 Replies

4. Shell Programming and Scripting

Trouble with passing Variable from bash to awk gsub command

Would really appreciate it if someone could point out my mistake in this line of code, i've been staring blankly at it trying everything i can think of some time now and coming up with nothing. #!/bin/bash echo "Enter Username" read Username awk -F: -v var=${Username} '/^var:/... (9 Replies)
Discussion started by: Nostyx
9 Replies

5. Shell Programming and Scripting

Passing string as variable(s) in bash

I'm trying to write a basic bash script that takes input you give (what directory, if any, what name, if any ....) and passes the information to find. I'm trying to just create a string with all variables and then pass it to find. So far I have this extremely simple: #!/bin/bash -f ... (2 Replies)
Discussion started by: Starting_Leaf
2 Replies

6. Shell Programming and Scripting

How to change Linux Terminal environment variable in a perl or bash script?

Hi, I meet an problem that it cannot change Terminal environment variable in a perl or bash script. This change can only exist and become effective in script lifetime. But I want to make this change take effect in current opened Terminal. In our view, the thought seems to be impossible, As... (9 Replies)
Discussion started by: weichanghe2000
9 Replies

7. Shell Programming and Scripting

Passing string from SQL to a BASH script

OS Solaris 10, DB oracle 10g Hello, We currently have a BASH script that runs and moves image files from a remote server to the local db server. A snippet of the code shows that we are picking up all Images that are 'mtime -1' some code... for file in `ssh user@10.200.200.10 'find... (3 Replies)
Discussion started by: JonP
3 Replies

8. Shell Programming and Scripting

Passing arguments to a bash script

Hi, I wanted to pass an argument to a bash script. So that the argument is used inside the awk command inside the bash script. I know the noraml way of passing argument to a bash script as below : sh myScript.sh abc Inside the bash script i can use like this myArg1=$1 wc $myArg But... (8 Replies)
Discussion started by: shree11
8 Replies

9. Shell Programming and Scripting

Passing variable from bash to perl script

Hi All, I need to pass a variable from bash script to perl script and in the perl script i am using those variables in the sql query but its giving error : Use of uninitialized value $ENV{"COUNTRYCD"} in concatenation (.) or string at /GIS_ROOT/custom/tables/DBread_vendor.pl line 50. Can ... (6 Replies)
Discussion started by: NileshJ
6 Replies

10. Web Development

Passing variable from PHP to bash script

I am totally new to PHP and I am trying to create a script that will as a user for a hostname and then use the "hostname" variable to generate a report using REST API. I am able to create the html script and php script to GET the "hostname" but I am having trouble passing the hostname variable... (10 Replies)
Discussion started by: kieranfoley
10 Replies
Spreadsheet::ParseExcel::Utility(3pm)			User Contributed Perl Documentation		     Spreadsheet::ParseExcel::Utility(3pm)

NAME
Spreadsheet::ParseExcel::Utility - Utility functions for Spreadsheet::ParseExcel. SYNOPSIS
use Spreadsheet::ParseExcel::Utility qw(ExcelFmt ExcelLocaltime LocaltimeExcel); # Convert localtime to Excel time my $datetime = LocaltimeExcel(11, 10, 12, 23, 2, 64); # 1964-3-23 12:10:11 print $datetime, " "; # 23459.5070717593 (Excel date/time format) # Convert Excel Time to localtime my @time = ExcelLocaltime($datetime); print join(":", @time), " "; # 11:10:12:23:2:64:1:0 # Formatting print ExcelFmt('yyyy-mm-dd', $datetime), " "; # 1964-3-23 print ExcelFmt('m-d-yy', $datetime), " "; # 3-23-64 print ExcelFmt('#,##0', $datetime), " "; # 23,460 print ExcelFmt('#,##0.00', $datetime), " "; # 23,459.51 DESCRIPTION
The "Spreadsheet::ParseExcel::Utility" module provides utility functions for working with ParseExcel and Excel data. Functions "Spreadsheet::ParseExcel::Utility" can export the following functions: ExcelFmt ExcelLocaltime LocaltimeExcel col2int int2col sheetRef xls2csv These functions must be imported implicitly: # Just one function. use Spreadsheet::ParseExcel::Utility 'col2int'; # More than one. use Spreadsheet::ParseExcel::Utility qw(ExcelFmt ExcelLocaltime LocaltimeExcel); ExcelFmt($format_string, $number, $is_1904) Excel stores data such as dates and currency values as numbers. The way these numbers are displayed is controlled by the number format string for the cell. For example a cell with a number format of '$#,##0.00' for currency and a value of 1234.567 would be displayed as follows: '$#,##0.00' + 1234.567 = '$1,234.57'. The "ExcelFmt()" function tries to emulate this formatting so that the user can convert raw numbers returned by "Spreadsheet::ParseExel" to a desired format. For example: print ExcelFmt('$#,##0.00', 1234.567); # $1,234.57. The syntax of the function is: my $text = ExcelFmt($format_string, $number, $is_1904); Where $format_string is an Excel number format string, $number is a real or integer number and "is_1904" is an optional flag to indicate that dates should use Excel's 1904 epoch instead of the default 1900 epoch. "ExcelFmt()" is also used internally to convert numbers returned by the "Cell::unformatted()" method to the formatted value returned by the "Cell::value()" method: my $cell = $worksheet->get_cell( 0, 0 ); print $cell->unformatted(), " "; # 1234.567 print $cell->value(), " "; # $1,234.57 The most common usage for "ExcelFmt" is to convert numbers to dates. Dates and times in Excel are represented by real numbers, for example "1 Jan 2001 12:30 PM" is represented by the number 36892.521. The integer part of the number stores the number of days since the epoch and the fractional part stores the percentage of the day. By applying an Excel number format the number is converted to the desired string representation: print ExcelFmt('d mmm yyyy h:mm AM/PM', 36892.521); # 1 Jan 2001 12:30 PM $is_1904 is an optional flag to indicate that dates should use Excel's 1904 epoch instead of the default 1900 epoch. Excel for Windows generally uses 1900 and Excel for Mac OS uses 1904. The $is1904 flag isn't required very often by a casual user and can usually be ignored. ExcelLocaltime($excel_datetime, $is_1904) The "ExcelLocaltime()" function converts from an Excel date/time number to a "localtime()"-like array of values: my @time = ExcelLocaltime($excel_datetime); # 0 1 2 3 4 5 6 7 my ( $sec, $min, $hour, $day, $month, $year, $wday, $msec ) = @time; The array elements from "(0 .. 6)" are the same as Perl's "localtime()". The last element $msec is milliseconds. In particular it should be noted that, in common with "localtime()", the month is zero indexed and the year is the number of years since 1900. This means that you will usually need to do the following: $month++; $year += 1900; See also Perl's documentation for localtime(): The $is_1904 flag is an optional. It is used to indicate that dates should use Excel's 1904 epoch instead of the default 1900 epoch. LocaltimeExcel($sec, $min, $hour, $day, $month, $year, $wday, $msec, $is_1904) The "LocaltimeExcel()" function converts from a "localtime()"-like array of values to an Excel date/time number: $excel_datetime = LocaltimeExcel($sec, $min, $hour, $day, $month, $year, $wday, $msec); The array elements from "(0 .. 6)" are the same as Perl's "localtime()". The last element $msec is milliseconds. In particular it should be noted that, in common with "localtime()", the month is zero indexed and the year is the number of years since 1900. See also Perl's documentation for localtime(): The $wday and $msec elements are usually optional. This time elements can also be zeroed if they aren't of interest: # sec, min, hour, day, month, year $excel_datetime = LocaltimeExcel( 0, 0, 0, 1, 0, 101 ); print ExcelFmt('d mmm yyyy', $excel_datetime); # 1 Jan 2001 The $is_1904 flag is also optional. It is used to indicate that dates should use Excel's 1904 epoch instead of the default 1900 epoch. col2int($column) The "col2int()" function converts an Excel column letter to an zero-indexed column number: print col2int('A'); # 0 print col2int('AA'); # 26 This function was contributed by Kevin Mulholland. int2col($column_number) The "int2col()" function converts an zero-indexed Excel column number to a column letter: print int2col(0); # 'A' print int2col(26); # 'AA' This function was contributed by Kevin Mulholland. sheetRef($cell_string) The "sheetRef()" function converts an Excel cell reference in 'A1' notation to a zero-indexed "(row, col)" pair. my ($row, $col) = sheetRef('A1'); # ( 0, 0 ) my ($row, $col) = sheetRef('C2'); # ( 1, 2 ) This function was contributed by Kevin Mulholland. xls2csv($filename, $region, $rotate) The "xls2csv()" function converts a section of an Excel file into a CSV text string. $csv_text = xls2csv($filename, $region, $rotate); Where: $region = "sheet-colrow:colrow" For example '1-A1:B2' means 'A1:B2' for sheet 1. and $rotate = 0 or 1 (output is rotated/transposed or not) This function requires "Text::CSV_XS" to be installed. It was contributed by Kevin Mulholland along with the "xls2csv" script in the "sample" directory of the distro. See also the following xls2csv utilities: Ken Prows' "xls2csv": http://search.cpan.org/~ken/xls2csv/script/xls2csv and H.Merijn Brand's "xls2csv" (which is part of Spreadsheet::Read): http://search.cpan.org/~hmbrand/Spreadsheet-Read/ AUTHOR
Maintainer 0.40+: John McNamara jmcnamara@cpan.org Maintainer 0.27-0.33: Gabor Szabo szabgab@cpan.org Original author: Kawai Takanori kwitknr@cpan.org COPYRIGHT
Copyright (c) 2009-2010 John McNamara Copyright (c) 2006-2008 Gabor Szabo Copyright (c) 2000-2006 Kawai Takanori All rights reserved. You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file. perl v5.10.1 2010-09-17 Spreadsheet::ParseExcel::Utility(3pm)
All times are GMT -4. The time now is 02:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy