Visit Our UNIX and Linux User Community

script to get parameters from 2 different files

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script to get parameters from 2 different files
# 1  
Old 10-11-2009
script to get parameters from 2 different files

Hi experts .
i have a script which will take parameters from a text file.
but now i need a script which will take 2 parameters from 2 different files or from a Excel sheet from 2 different columns.

i have the script as follows (which will take parameter from a txt file).

echo "executing sql query"
while read source
sqlplus -s $k/$p@$d <<EOI>>output.txt
set serveroutput on
set heading off
set linesize 200
set trimspool on
set echo off
set markup HTML off
set feedback off
set termout off
set pagesize 250
set verify off
set pages 1000
select * from Table where columnn like '%$source%');

Now i want a script which will read 2 parameters from different files.

Thanks Mohan
# 2  
Old 10-11-2009
Post file sample and required data.
# 3  
Old 10-11-2009
build a combined parameter file in a separate loop, then loop thru the "combined" file for your sql.
# 4  
Old 10-12-2009
hi danmero..
actually i am trying to create a script which will move all the files from Old server to new server.(2 different servers)
i have 2 files (old_paths.txt and new_paths.txt)
For each old path in old_path.txt there is a corresponding new path mentioned in the new_path.txt. (both the files contain absolute paths)
My script should take parameter from both the text files... and move all the files from old to new server ... the script which i have in my mind is something like as follows : (which i will run in new server)

quote USER $USER
quote PASS $PASS
echo "copying the Files"
#echo "----------------------------"#
while read parameter1 parameter2 ------ this line is wrong
lcd $parameter1 ------ this line is wrong
cd $parameter2 ------ this line is wrong
mget *.*
# 5  
Old 10-12-2009
ok, so assuming there is a 1:1 correspondence betw. lines in each file, i.e.,
file1:      file2:
dir1        dir1a
dir2        dir2a

you can paste these together into a param file
paste file1 file2 > combined

then you can iterate over that to populate an ftp macdef.

or if you can use sftp, you could instead put the contents of 'paste' into a var and iterate over the var to create a command batch file, and feed that to 'sftp -b [batchfile]'

by using a variable and then feeding that to a loop, you'll get alternating lines from each file:

COMBINED=`paste file1 file2`
for each in $COMBINED
   if [ $COUNT % 2 ]
     echo "cd $each" >> batch
     echo "mget *.*" >> batch
     echo "lcd $each" >> batch
   COUNT=`expr $COUNT + 1`   

Previous Thread | Next Thread
Test Your Knowledge in Computers #251
Difficulty: Easy
MILNET was designed for highly classified military communications.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to create runtime variables based on the number of parameters passed in the script

Hi All, I have a script which intends to create as many variables at runtime, as the number of parameters passed to it. The script needs to save these parameter values in the variables created and print them ---------- export Numbr_Parms=$# export a=1 while do export... (3 Replies)
Discussion started by: dev.devil.1983
3 Replies

2. UNIX for Dummies Questions & Answers

Perl Script:how to find how many parameters are required to run the script

How to find how many parameters are required to run a Perl script? (1 Reply)
Discussion started by: Lakshman_Gupta
1 Replies

3. Shell Programming and Scripting

What extra Parameters I can use for archiving log files

Hello All, I have developed a script which takes following parameter from the input file to archive log files 1)Input Path 2)File pattern(*.csv) 3)Number of days(+1) Following is the algorithm of my script Read the input file go to that path and search for particular n days older... (3 Replies)
Discussion started by: mitsyjohn
3 Replies

4. Shell Programming and Scripting

Shell script compare all parameters in two files and display results

Hi , I am not familiar with shell programming. I have a requirement like i have two files .I need to compare the two files by comparing each parameter and i should produce 2 outputs. 1)i have around 35 parameters say i have one parameter name called db_name=dcap in one file and... (7 Replies)
Discussion started by: muraliinfy04
7 Replies

5. Shell Programming and Scripting

want to pass parameters to awk script from shell script

Hello, I have this awk script that I want to execute by passing parameters through a shell script. I'm a little confused. This awk script removes duplicates from an input file. Ok, so I have a .sh file called #!/usr/bin/sh... (4 Replies)
Discussion started by: script_op2a
4 Replies

6. UNIX for Dummies Questions & Answers

Create a shell script for write files with 2 parameters

Hello, I'm a newbie in shell script. So, i would like to create a shell script which take 2 IN parameters (PARAM1 and PARAM2). This script need to create 2 files as : I need to create this file /etc/apache2/sites-available/PARAM2 : <VirtualHost *:80> DocumentRoot "/home/PARAM1/www"... (0 Replies)
Discussion started by: chatlumo
0 Replies

7. AIX

tuning network parameters : parameters not persist after reboot

Hello, On Aix 5.2, we changed the parameters tcp_keepinit, tcp_keepintvl and tcp_keepidle with the no command. tunrestore -R is present in inittab in the directory /etc/tunables we can clearly see the inclusion of parameters during reboot, including the file lastboot.log ... (0 Replies)
Discussion started by: dantares
0 Replies

8. Shell Programming and Scripting

call a script from another script passing parameters

I want to call script2 from script1 passing parameters. I want to read the parameters list in script1, check the local directory (for example - lpath1|lpath2|lpath3|lpath4|lpath5|) for the existance of files and set the` lcount` to the number of files in this folder (`... (2 Replies)
Discussion started by: Lenora2009
2 Replies

9. Shell Programming and Scripting

passing multiple files as parameters

hi all i am etl guy i have shell script that i use to do processing on file. the problem is that i want it to use on multiple files at same time is there any way of passing the file name since my all my filename start with samename like abc* p,ease let me know (4 Replies)
Discussion started by: er_zeeshan05
4 Replies

10. Shell Programming and Scripting

help me in sending parameters from sqlplus script to unix shell script

Can anybody help me out in sending parameters from sql*plus script to unix shell script without using flat files.. Initially in a shell script i will call sql*plus and after getting some value from some tables, i want that variable value in unix shell script. How can i do this? Please tell me... (2 Replies)
Discussion started by: Hara
2 Replies

Featured Tech Videos