script to write script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script to write script
# 1  
Old 03-07-2006
script to write script

i have scripts files to create mq objects. When I have to do that in another machine, I have to copy all of them and change a few parameters from some of the files. I think, if I create a script file which takes me these parameters as input ( not sure whether we can give a file as an input of type when run only) and have all the scripts creates different scrpts file, that would be very helpful. what i mean is

say i have a script file called FF.

aaaa xxx
bbb yyy

what i want to do is
echo "aaaa xxx" >FF
echo "bbb yyy">>FF

Also want to replace if the xxx is variable. some of the parameters are fixed some of them are variable.

there are about 10 scripts file. So, I like to read one by one and create file which i can copy and use in new machine.

Can some one help me how i can do that

thanks
# 2  
Old 03-08-2006
You can do the job whith macros:

$ cat FF
aaaa xxx
bbb yyy

echo "define(xxx,TEST)">out.macros


$ cat out.macros FF|m4 -B64556

aaaa TEST
bbb yyy


Bye.
# 3  
Old 03-08-2006
my need is to do what with many scripits files. NOt only one. The script need to pick up a file, write that, go and pick up another etc.

Also, can I give a file as an input?

thanks
# 4  
Old 03-08-2006
There“re multiples ways to solve the problem, basically if u do the job for one file u can do it again for other:

exem.sh:
input=$1
output=$2
{
i=1
while read line
do
FILE=$(echo $line|awk -F\; '{print $1}')
macro=$(echo $line|awk -F\; '{print $2}')
echo "${macro}$(cat ${FILE})"|m4 -B64556
(( i +=1 ))
done >${output}
} < ${input}
exit 0

where

file.one:
aaaa xxx
bbb yyy

file.two:
aaaa xxx
bbb yyy

file.conf(INPUT):
file.one;define(xxx,TEST)
file.two;define(yyy,TEST)

out(OUTPUT):
aaaa TEST
bbb yyy
aaaa xxx
bbb TEST


Cheers
# 5  
Old 03-09-2006
Thank you but I still did not understand how it takes up all files in the scripts directory. I will run this script in a directory where there are scripts files and I want to generate one single scripts files which generates back the scripts file into another directory but with certain parameter and file name different.

say the original directory has 6 scripts file named as

create_aaaaa
start_aaaaa
sopt_aaaaa

start_rc_aaaaa
stop_rc_aaaaa

also there are certain commands in the above files and other files whose name can be the same use aaaaa as a parameters. So, my need is create a sngle file as

echo " start_$1" >create_$1
echo " dis chl(q1.q2)" | runmqsc QM1 >>create_$1

The script file I am plannign to create has to create this single script file i explained above. It read files, add echo " takes line" > filename, if there is the parameter to change, it changes if not direct to the orignal file name

as >stoplsr
I mean this file name remains same in new directory too.

The single script file contans all the commands of all scripts files in the original script directory but paratemter changed. When I run this single script file inot new directory. similar set of files are created in the new directory but with part of file name different and some parameter name dirrerent inside some file name.

This script file has to take min 5 parameters to 10. Can these be put into a file and read as an input.

I maen, lets say out scrit to generate a single script file from a group of scripts file is generator. It has to take a file an an input where there are parameter

generator <inputfile

this generator, picks up all the scripts file one by one and generates a script file as

echo " command line, " > file name( may be start_$1)

the first part start_ is taken from the read file.

thanks
# 6  
Old 03-13-2006
Power

Perhaps I don't understand the problem, but this looks like a strange approach.
It looks to me as if you want to generate sets of customised scripts using parameter files to define any variable items. Wouldn't it be easier to create a set of standard scripts with all the variable items parameterised and pick up the values from a file or the command line?

cheers
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Please write a script for me

Hi All, need one help Suppose there are two files- 1)Input files-: path1/given/to/file | File1 path2/given/to/file | file 2 etc Note- I use "|" as variable separator. 2) Target files- I want to fetch data from file1 and use in below command-: cd /path(from 1st file) ls -ltr If file(From... (2 Replies)
Discussion started by: Shubham
2 Replies

2. Shell Programming and Scripting

How to write config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

3. UNIX for Dummies Questions & Answers

How to write Config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

4. Shell Programming and Scripting

Need help to write script

I am having a File format as mentioned below Employee id|Name|Languages 12345|Hema|02|English|Hindi 4567|Basha|03|Engligh|Hindi|Telegu the 02 and 03 are counters. Using that we need to generate the output records as mentioned below 12345|Hema|English 12345|Hema|Hindi ... (8 Replies)
Discussion started by: bashamsc
8 Replies

5. Shell Programming and Scripting

Please help me to write the script

Hi All, I have written the follwing script to take the backup of the file every day along with the date. DATE=`date +%Y%m%d` export DATE cp var/hr/hr333m.txt cp var/hr/payments/hr333m_$DATE.txt The file name as follows after taking the backup. hr333m_20110630.txt Could you... (3 Replies)
Discussion started by: ajaykumarkona
3 Replies

6. AIX

how to write this script?

If I need delete some disk, for i in hdisk1 hdisk2 hdisk3 hdisk4 do rmdev -dl $i done if I have more than 100 hdisks, how to write a script like that to delete them? (6 Replies)
Discussion started by: rainbow_bean
6 Replies

7. Shell Programming and Scripting

Better way to write this script

Hi All, I have written the following script. I have just repeated some commands, and I am sure there is a more better way to do it. I hope I one of gurus here will help me make it in a better shape. Here is the script: #! /bin/sh sed -i -e "s/test2.xxx/test3.xxx/" -e "s/output2/output3/"... (2 Replies)
Discussion started by: faizlo
2 Replies

8. UNIX for Dummies Questions & Answers

Should I write a PERL Script or Shell Script?

Hello, I have done some BASIC shell scripting/PERL scripting before so I am familiar with the languages. I am not really sure which one would lend itself better to the application I have to write. I am required to scan the message logs for possible break in attempts. If I use shell scripting... (2 Replies)
Discussion started by: mojoman
2 Replies

9. Shell Programming and Scripting

Help me to write the script

Actually i am working with two diffrent files having same structure each file contain Ten diffrent column and i want to write a script which will compare the colummns of first file with the column of second file and diiference will be send to the first column of third file . similarly for... (5 Replies)
Discussion started by: gyana_cboy
5 Replies

10. Shell Programming and Scripting

Help! Need to write my first script

Hi Folks! I am a MacUser and am trying to learn Unix for the last few months. I will explain in detail what I am trying to do, and apreciate you help if you can teach me even if it is a single comand line inside the script. I own a small company, where I manufacture special gypsums and... (5 Replies)
Discussion started by: fundidor
5 Replies
Login or Register to Ask a Question