Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Issue with use of Configuration file instead of hardcoded values inside the script Post 302543003 by irudayaraj on Friday 29th of July 2011 07:36:10 AM
Old 07-29-2011
Issue with use of Configuration file instead of hardcoded values inside the script

Hi,

My code works perfectly fine.
But,
Code:
$my $min_to_add = 1 * 1 * 60;

and
Code:
my $hr_to_sub = 1 * 1 * 86400;

i may need to change the values in future. so am keeping them in a separate configuration file like

Code:
MIN = 1 * 1 * 60 
HR = 24 * 60 * 60

in the script, i use a package use et_config and Et_Config_Init()
I call them inside the script like
Code:
my $min_to_add = Et_Config_Value("MIN");
my $hr_to_sub = Et_Config_Value("HR");

The issue here is, when i use those values directly in the script, it takes the multiplied value as 1 * 1 * 60 =60 but when i get them from the configuration file, it remains as 1 * 1 * 60 only as such , so i am not getting the result expected.

Is there any function that can do this?
The configuration file is mandatory. How can this be achieved?

Code:

Code:
my $date_var = "Jun 6 2011 8:02AM";
if ($date_var != '')
{
my $min_to_add = 1 * 1 * 60;
my $from_dt = qx/
date -d "$date_var" +%s
/ + $min_to_add;
my $min_var = strftime( '%B %d %Y %I:%M%p', localtime $from_dt );
print("\n the mins added is $min_var\n");

my $hr_to_add = 1 * 60 * 60;
my $to_dt = qx/
date -d "$min_var" +%s
/ + $hr_to_add;
my $hr_var = strftime( '%B %d %Y %I:%M%p', localtime $to_dt );
print("\n the hours added is $hr_var\n");
}
else
{
use POSIX qw(strftime);
my $to_dt = strftime "%b %d %Y %H:%M%p", localtime;
print("\n The original time is $to_dt\n");
my $hr_to_sub = 1 * 1 * 86400;
my $from_dt
= qx/
date -d "$to_dt" +%s
/ - $hr_to_sub;
my $to_dt_now = strftime( '%B %d %Y %H:%M%p', localtime $from_dt );
print("\n the to date now is $to_dt_now \n");
}


Last edited by pludi; 07-29-2011 at 08:48 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

script to read configuration file

Hi, I would like to write a Korn shell script which will remove files older than a certain date. In my script, it will read a configuration file with the following entries: # <directory> <filename wildcard> # /home/philip/log *.log /home/philip/log1 delete-me*.log The... (1 Reply)
Discussion started by: philip_dba
1 Replies

2. Shell Programming and Scripting

how to find Script file location inside script

I have to find out the file system location of the script file inside script. for example a script "abc.sh" placed anywhere in the file system when executed shold tell by itself the location of it. example #pwd / #./abc this is / #cd /root #./abc this is /root #cd / #/root/abc this... (10 Replies)
Discussion started by: asami
10 Replies

3. Shell Programming and Scripting

Webalizer issue when inside script

hello gurus, When i run the command on shell webalizer -p -n mydomain.com -c /path/to/my/log/webalizer.conf it works fine and it creates stats for the given mydomain.com in the target output directory but when i put it in a script same command and parameters but it goes weird and it... (0 Replies)
Discussion started by: eyes_drinker
0 Replies

4. Shell Programming and Scripting

connection string is hardcoded

Hi, I have many perl scripts in single server, i am new to perl, suggestions are appreciated. connection string is hardcoded in all perl scripts i need to make change the all perl scripts and there should be only one config file available in that server. destination database is mysql... (3 Replies)
Discussion started by: prakash.gr
3 Replies

5. Shell Programming and Scripting

extracting values from configuration file

Dear All, i am new to shell scripting, I am working on embedded system based on linux.I am supposed to the read the configuration file and edit another file. presently I would like to read from the configuration file.It would be having values file one below. There is chance of entering... (6 Replies)
Discussion started by: Ratheendran
6 Replies

6. Shell Programming and Scripting

Script to increase Timeout values in Configuration File

Hi Guys I am using one configuration file for reading some time out values.The format of the file is A.Type = Number A.Val = 2000 B.Type = Number B.Val = 4000 Now my requirement is I need to write a shell script in Solaris where i need to increase these timeout values by 10 times of... (3 Replies)
Discussion started by: mr_deb
3 Replies

7. Shell Programming and Scripting

error in shell script while returning values-- urgent issue plz help.

Hi, I have initailized a varaible EBID as typeset Long EBID=0 i am calculating value of EBID using certian formula as below: (( CURR_EBID= ($BANDINDEX << 27) | ($CURR_FREQ << 16) | ($CURR_CELLID << 4) | $CURR_SECTOR_VALUE )) return $CURR_EBID The output is as below: + (( CURR_EBID=... (6 Replies)
Discussion started by: kasanur
6 Replies

8. Shell Programming and Scripting

Taking sum up all values inside the file

Hi, Taking sum up all values inside the file by using the below command: paste -sd+ filenmae | bc Getting some error like "0705-001: building space exceeded on line1 stdin" The original data looks like SPACE SPACE SPACE 0.123 JOBNAME1 SPACE SPACE 20.325 JOBNAME2 SPACE SPACE... (2 Replies)
Discussion started by: NareshN
2 Replies

9. Shell Programming and Scripting

Issue with ls command inside script

Hi , DIR1 has only one file with .txt extension , trying to get the size of that file using the following script #!/bin/ksh foldr_1="/etc/DIR1" #echo "$foldr_1" sze_fdr1=$(ls -ltr foldr_1/*.txt |awk '{ print $5 }') echo "$sze_fdr1" After executing the above script getting... (1 Reply)
Discussion started by: smile689
1 Replies

10. UNIX for Beginners Questions & Answers

Replacing values inside a file.

Good day guys, I'm having trouble in creating a logic when it comes to replacing the values inside a file. I tried using sed command but it just doesn't work the way I want it to be. Here is what I'm trying to achieve. If my input file contains the values below. NAME++GUEST1 ++GUESS2++... (3 Replies)
Discussion started by: asdfghjkl
3 Replies
ppmtosixel(1)                                                 General Commands Manual                                                ppmtosixel(1)

NAME
ppmtosixel - convert a portable pixmap into DEC sixel format SYNOPSIS
ppmtosixel [-raw] [-margin] [ppmfile] DESCRIPTION
Reads a portable pixmap as input. Produces sixel commands (SIX) as output. The output is formatted for color printing, e.g. for a DEC LJ250 color inkjet printer. If RGB values from the PPM file do not have maxval=100, the RGB values are rescaled. A printer control header and a color assignment table begin the SIX file. Image data is written in a compressed format by default. A printer control footer ends the image file. OPTIONS
-raw If specified, each pixel will be explicitly described in the image file. If -raw is not specified, output will default to com- pressed format in which identical adjacent pixels are replaced by "repeat pixel" commands. A raw file is often an order of magni- tude larger than a compressed file and prints much slower. -margin If -margin is not specified, the image will be start at the left margin (of the window, paper, or whatever). If -margin is speci- fied, a 1.5 inch left margin will offset the image. PRINTING
Generally, sixel files must reach the printer unfiltered. Use the lpr -x option or cat filename > /dev/tty0?. BUGS
Upon rescaling, truncation of the least significant bits of RGB values may result in poor color conversion. If the original PPM maxval was greater than 100, rescaling also reduces the image depth. While the actual RGB values from the ppm file are more or less retained, the color palette of the LJ250 may not match the colors on your screen. This seems to be a printer limitation. SEE ALSO
ppm(5) AUTHOR
Copyright (C) 1991 by Rick Vinci. 26 April 1991 ppmtosixel(1)
All times are GMT -4. The time now is 07:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy