The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Passing Filename as a Parameter to Another script ravisg Shell Programming and Scripting 1 05-07-2008 11:28 PM
url calling and parameter passing to url in script gander_ss UNIX for Advanced & Expert Users 1 05-07-2008 12:34 PM
passing parameter 4m shell script to a DB stored procedure hema2026 Shell Programming and Scripting 0 11-16-2007 06:55 AM
passing parameter from Shell-script to Sql-script subodhbansal Shell Programming and Scripting 0 09-21-2007 06:15 AM
parameter file for a shell script bryan Shell Programming and Scripting 2 02-25-2005 12:58 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-29-2008
Amit.Sagpariya Amit.Sagpariya is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 111
Passing parameter from one file to shell script

Hi All,

I have a 2 files. File1 i am generating using an ETL tool, which is a comman seperated delimited file which contains country code & load date.
everytime, this country code will be updated from a table. It might be AB or BA & ld_date will be for which date we need to load the file.

In file2.sh script which is doing feed validation test for the feed file, i need to pass this country code & load date.

File1
====
COUNTRYCODE,LD_DATE
AB,20081210

File2.sh
======
echo $1 $2

Can someone tell me if it is possible to pass in this manner. Because i need to call File2.sh thru ETL tool. so i cannot manually change the parameter daily. I need to pass this parameter dynamically for each run.
  #2 (permalink)  
Old 10-29-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Wink It appears to make sense

Take a look at the following. I inserted the "2*" into the script just to verify/show what was doing the echo.

> cat file1
COUNTRYCODE,LD_DATE
AB,20081210

> cat file2.sh
echo "2*" $1 $2

> while read var1 var2; do file2.sh $var1 $var2; done <file1
2* COUNTRYCODE,LD_DATE
2* AB,20081210
  #3 (permalink)  
Old 10-29-2008
Amit.Sagpariya Amit.Sagpariya is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 111
Hi joeyg,

Thanks for your input.

But what i want is... it must be like...

./file2.sh AB 20081210

while executing above code, i am not getting what i wanted.

Thank for ur help
  #4 (permalink)  
Old 10-29-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Question

What are you getting for output?
It looks like it should be fine.

Last edited by joeyg; 10-29-2008 at 08:01 AM.. Reason: corrected spelling
  #5 (permalink)  
Old 10-29-2008
Amit.Sagpariya Amit.Sagpariya is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 111
Hi Joeyg,

I found the answer.

file1
====
COUNTRYCODE,LD_DATE
AB,20081210

file2.sh
======
#!/bin/sh
var1=`sed '1d' File1 | cut -d, -f1`
var2=`sed '1d' File1 | cut -d, -f1`

echo $var1
echo $var2
  #6 (permalink)  
Old 10-29-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Wink

OK, I see what you are doing... eliminating the header row with the sed command.
Although I think your var2 should be a cut with an f2 -- you want the second entry on that line. Right?
  #7 (permalink)  
Old 10-29-2008
Amit.Sagpariya Amit.Sagpariya is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 111
yes, u r right sorry for typo.....
Closed Thread

Bookmarks

Tags
parameter passing

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:04 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0