Sponsored Content
Top Forums Shell Programming and Scripting Repeating variables in the code Post 302106382 by mahalakshmi on Thursday 8th of February 2007 05:41:45 AM
Old 02-08-2007
Repeating variables in the code

Hi all,
I had written 3 KSH scripts for different functionalities. In all these 3 files there are some 30 variables in common. So I want to reduce the code by placing these variables in a common properties file named (dataload.prop/dataload.parms/dataload.txt) or txt file and access it in the 3 programs from one program.

Please do tell me how to call that properties file from a ksh program.

Thanks
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Omit repeating lines

Can someone help me with the following 2 objectives? 1) The following command is just an example. It gets a list of all print jobs. From there I am trying to extract the printer name. It works with the following command: lpstat -W "completed" -o | awk -F- '{ print $1}' Problem is, I want... (6 Replies)
Discussion started by: TheCrunge
6 Replies

2. Shell Programming and Scripting

Repeating commands in a script

I have written a script that I want to be repeated. The script that I wrote outputs the date, how many people are on the system, how many people logged in before me, and how many people logged in after me. Than what I want it to do is after it outputs the 4 lines I want it to go back to the... (4 Replies)
Discussion started by: Dave2874
4 Replies

3. Programming

including shell env variables into C code

Hey, I'm brushing up on C code and I'm trying to incorporate the shell environmental variables into standard ansi C code. For example I just want to do the equivalent of --echo $PATH-- and implement that in standard ansi C code. How would I do that? Thanks (4 Replies)
Discussion started by: bdsffl
4 Replies

4. Shell Programming and Scripting

Value repeating problem in columns

Hi, I have a file like this 0817 0201364 1 866 . . . . . . . 574 . 100.0 100.0 5529737 1 TV 0817 0201364 2 1440 . . . . . . . . . . . 5529737 1 TV 0817 0201364 6 1323 . . . . ... (2 Replies)
Discussion started by: Sandeep_Malik
2 Replies

5. Shell Programming and Scripting

Repeating Substitution Command on VI

Hello Folks, how to write a command on vi that allow to repeat last substitution command? Here what I want to do : 1 2 3 1 2 3 1 2 3 :.,+2s/\n/ /And I obtain : 1 2 3 1 2 3 1 (5 Replies)
Discussion started by: gogol_bordello
5 Replies

6. Shell Programming and Scripting

Repeating loop between dates

Hi , I need to execute set of commands between two parameterized dates. Suppose, If parameter1 is Feb1st-2010 and parameter2 is November15th-2010. I need to execute a set of commands within these dates . can any one help me to build a loop so that it should execute for 28days in February... (4 Replies)
Discussion started by: Raamc
4 Replies

7. Homework & Coursework Questions

repeating test several times

echo "Enter Number of times u want this to be run" read RUN for i in {1..$RUN} do echo "i am going to market" done now the issue is that when i run this script it ask me "Enter Number of times u want this to be run" and then i put the value ,say i put 10, but when the script runs it gives... (1 Reply)
Discussion started by: bharat8007
1 Replies

8. Shell Programming and Scripting

auto-generating assembly code by variables found by script

Hi everybody I'm working on a list of registers(flip-flops to be exact), now i need to extract some value from this list and use them as arguments to pass them to some assembly code for example i have: 118 chain79 MASTER (FF-LE) FFFF 1975829 /TCK F FD1TQHVTT1 ... (1 Reply)
Discussion started by: Behrouzx77
1 Replies

9. UNIX for Dummies Questions & Answers

Need help with repeating variables in a shell script

I should preface this by saying I have never worked with shell scripts before so this is all new to me. I was able to make something that worked, but is terribly optimized, and I have no idea how to improve it. If anything it's a pretty hilarious script: #/bin/bash get_char() { ... (4 Replies)
Discussion started by: ricco19
4 Replies

10. UNIX for Dummies Questions & Answers

Adding variables to repeating strings

Hello, I want to add a letter to the end of a string if it repeats in a column. so if I have a file like this: DOG001 DOG0023 DOG004 DOG001 DOG0023 DOG001 the output should look like this: DOG001-a DOG0023-a DOG004 DOG001-b (15 Replies)
Discussion started by: verse123
15 Replies
Test::LectroTest(3pm)					User Contributed Perl Documentation				     Test::LectroTest(3pm)

NAME
Test::LectroTest - Easy, automatic, specification-based tests SYNOPSIS
#!/usr/bin/perl -w use MyModule; # contains code we want to test use Test::LectroTest; Property { ##[ x <- Int, y <- Int ]## MyModule::my_function( $x, $y ) >= 0; }, name => "my_function output is non-negative" ; Property { ... }, name => "yet another property" ; # more properties to check here DESCRIPTION
This module provides a simple (yet full featured) interface to LectroTest, an automated, specification-based testing system for Perl. To use it, declare properties that specify the expected behavior of your software. LectroTest then checks your software to see whether those properties hold. Declare properties using the "Property" function, which takes a block of code and promotes it to a Test::LectroTest::Property: Property { ##[ x <- Int, y <- Int ]## MyModule::my_function( $x, $y ) >= 0; }, name => "my_function output is non-negative" ; The first part of the block must contain a generator-binding declaration. For example: ##[ x <- Int, y <- Int ]## (Note the special bracketing, which is required.) This particular binding says, "For all integers x and y." (By the way, you aren't limited to integers. LectroTest also gives you booleans, strings, lists, hashes, and more, and it lets you define your own generator types. See Test::LectroTest::Generator for more.) The second part of the block is simply a snippet of code that makes use of the variables we bound earlier to test whether a property holds for the piece of software we are testing: MyModule::my_function( $x, $y ) >= 0; In this case, it asserts that "MyModule::my_function($x,$y)" returns a non-negative result. (Yes, $x and $y refer to the same x and y that we bound to the generators earlier. LectroTest automagically loads these lexically bound Perl variables with values behind the scenes.) Note: If you want to use testing assertions like "ok" from Test::Simple or "is", "like", or "cmp_ok" from Test::More (and the related family of Test::Builder-based testing modules), see Test::LectroTest::Compat, which lets you mix and match LectroTest with these modules. Finally, we give the whole Property a name, in this case "my_function output is non-negative." It's a good idea to use a meaningful name because LectroTest refers to properties by name in its output. Let's take a look at the finished property specification: Property { ##[ x <- Int, y <- Int ]## MyModule::my_function( $x, $y ) >= 0; }, name => "my_function output is non-negative" ; It says, "For all integers x and y, we assert that my_function's output is non-negative." To check whether this property holds, simply put it in a Perl program that uses the Test::LectroTest module. (See the "SYNOPSIS" for an example.) When you run the program, LectroTest will load the property (and any others in the file) and check it by running random trials against the software you're testing. Note: If you want to place LectroTest property checks into a test plan managed by Test::Builder-based modules such as Test::Simple or Test::More, see Test::LectroTest::Compat. If LectroTest is able to "break" your software during the property check, it will emit a counterexample to your property's assertions and stop. You can plug the counterexample back into your software to debug the problem. (You might also want to add the counterexample to a list of regression tests.) A successful LectroTest looks like this: 1..1 ok 1 - 'my_function output is non-negative' (1000 attempts) On the other hand, if you're not so lucky: 1..1 not ok 1 - 'my_function output is non-negative' falsified in 324 attempts # Counterexample: # $x = -34 # $y = 0 EXIT CODE
The exit code returned by running a suite of property checks is the number of failed checks. The code is 0 if all properties passed their checks or N if N properties failed. (If more than 254 properties failed, the exit code will be 254.) ADJUSTING THE TESTING PARAMETERS
There is one testing parameter (among others) that you might wish to change from time to time: the number of trials to run for each property checked. By default it is 1,000. If you want to try more or fewer trials, pass the "trials=>"N flag: use Test::LectroTest trials => 10_000; TESTING FOR REGRESSIONS AND CORNER CASES
LectroTest can record failure-causing test cases to a file, and it can play those test cases back as part of its normal testing strategy. The easiest way to take advantage of this feature is to set the regressions parameter when you "use" this module: use Test::LectroTest regressions => "regressions.txt"; This tells LectroTest to use the file "regressions.txt" for both recording and playing back failures. If you want to record and play back from separate files, or want only to record or play back, use the record_failures and/or playback_failures options: use Test::LectroTest playback_failures => "regression_suite_for_my_module.txt", record_failures => "failures_in_the_field.txt"; See Test::LectroTest::RegressionTesting for more. CAVEATS
When you use this module, it imports all of the generator-building functions from Test::LectroTest::Generator into the your code's namespace. This is almost always what you want, but I figured I ought to say something about it here to reduce the possibility of surprise. A Property specification must appear in the first column, i.e., without any indentation, in order for it to be automatically loaded and checked. If this poses a problem, let me know, and this restriction can be lifted. SEE ALSO
For a gentle introduction to LectroTest, see Test::LectroTest::Tutorial. Also, the slides from my LectroTest talk for the Pittsburgh Perl Mongers make for a great introduction. Download a copy from the LectroTest home (see below). Test::LectroTest::RegressionTesting explains how to test for regressions and corner cases using LectroTest. Test::LectroTest::Compat lets you mix LectroTest with the popular family of Test::Builder-based modules such as Test::Simple and Test::More. Test::LectroTest::Property explains in detail what you can put inside of your property specifications. Test::LectroTest::Generator describes the many generators and generator combinators that you can use to define the test or condition space that you want LectroTest to search for bugs. Test::LectroTest::TestRunner describes the objects that check your properties and tells you how to turn their control knobs. You'll want to look here if you're interested in customizing the testing procedure. LECTROTEST HOME
The LectroTest home is http://community.moertel.com/LectroTest. There you will find more documentation, presentations, mailing-list archives, a wiki, and other helpful LectroTest-related resources. It's also the best place to ask questions. AUTHOR
Tom Moertel (tom@moertel.com) INSPIRATION
The LectroTest project was inspired by Haskell's QuickCheck module by Koen Claessen and John Hughes: http://www.cs.chalmers.se/~rjmh/QuickCheck/. COPYRIGHT and LICENSE Copyright (c) 2004-05 by Thomas G Moertel. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.12.3 2007-08-30 Test::LectroTest(3pm)
All times are GMT -4. The time now is 08:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy