LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-15-2008, 06:51 AM   #1
intikhabalam
LQ Newbie
 
Registered: Jul 2008
Posts: 6

Rep: Reputation: 0
Unhappy Trying to use FOR loop variable to create files but failed, plz help


for myvar in $(cat $filename)
do
sqlplus -s a/a@b @GetPatchItemsQry.sql $myvar
done > tmpPatchItemsqry"$myvar"a.sql


here i want to create the multiple files, means, one file with one myvar variable value but programme create only one file with

tmpPatchItemsqry"$myvar"a.sql

name.

Plz help
 
Old 07-15-2008, 07:00 AM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Well, you have $filename in the beginning.. what is it's value since it's defined as a variable?
 
Old 07-15-2008, 09:46 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Also, shouldn't it be

Code:
for myvar in $(cat $filename)
do
sqlplus -s a/a@b @GetPatchItemsQry.sql $myvar >tmpPatchItemsqry${myvar}a.sql
done
 
Old 07-16-2008, 01:00 AM   #4
intikhabalam
LQ Newbie
 
Registered: Jul 2008
Posts: 6

Original Poster
Rep: Reputation: 0
Unhappy

Quote:
Originally Posted by trickykid View Post
Well, you have $filename in the beginning.. what is it's value since it's defined as a variable?

That contain the file name, Actually in this script i am downloading the files from DIMENSIONS server using BASELINE name, This script will get the BASELINE name from CSV file then connect to DIMENSIONS server and get the File names and path.

This CSV file contains more than one BASELINES now i want that, this script will generate Filenames and paths for one BASELINE in one file. This script is generating the FILENAMES and PATHS correctly but does not generate multiple files. now plz send me an example , how to create multiple files in a loop. thanks in advance.
 
Old 07-16-2008, 01:28 AM   #5
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Well, can you post the other script or scripts so we can see where the problem is?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to define a variable In a while loop? fatsheep Programming 16 07-30-2014 01:12 PM
define multiple variable through loop in makefiles sun_sun Programming 1 11-28-2007 08:16 AM
Shell variable in Linux is reset after while loop CBenner Programming 7 05-19-2006 09:46 AM
incrementing variable in an until loop jeffreybluml Programming 2 05-12-2005 07:45 AM
getting a variable out of a WHILE loop. fhinkle Programming 8 02-22-2005 04:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration