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 > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Capturing Sybase SP output in Shell Script rajpreetsidhu Shell Programming and Scripting 2 08-19-2009 09:50 AM
help me in sending parameters from sqlplus script to unix shell script Hara Shell Programming and Scripting 2 01-29-2008 03:31 PM
DB2 stored procedure (with input parameters) from script mpang_ Shell Programming and Scripting 1 12-13-2006 08:12 AM
Capturing shell script command output designflaw Shell Programming and Scripting 2 03-01-2006 04:24 PM
Need help capturing pipe to a file in shell script heinz Shell Programming and Scripting 6 11-03-2005 08:27 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 3 Weeks Ago
wtolentino wtolentino is offline
Registered User
  
 

Join Date: Oct 2005
Posts: 33
Capturing Input Parameters on Shell Script

i have this basic line of code that doesn't work. i simply want to get the input parameter strings but when the script is run it appears that the first parameter is assigning the value to the second parameter.

Code:
#!/bin/sh

pdir=`pwd`
p1=$1
p2=$2

echo "directory: $pdir\n"
echo "parameter 1: $p1\n"
echo "parameter 2: $p2\n"
Code:
$ sh sample_file.sh /u02/app/ccalloc/dev/out/*.txt /export/home/ccalftdv
directory: /export/home/ccalftdv/apps

parameter 1: /u02/app/ccalloc/dev/out/EATVDAILY02132008.txt

parameter 2: /u02/app/ccalloc/dev/out/EATVDAILY02132008.txt

$ sh sample_file.sh /u02/app/ccalloc/dev/out/*.txt /export/home/ccalftdv
directory: /export/home/ccalftdv/apps

parameter 1: /u02/app/ccalloc/dev/out/EATVDAILY02132008.txt

parameter 2: /u02/app/ccalloc/dev/out/EATVDAILY03292007.txt

$
eventhough on the code it does not directly assign any to the second parameter.

i need to get the strings for each parameter e.g.:
Code:
$ sh sample_file.sh /u02/app/ccalloc/dev/out/*.txt /export/home/ccalftdv

parameter 1: /u02/app/ccalloc/dev/out/*.txt 

parameter 2: /export/home/ccalftdv
how do i do that? thanks.
  #2 (permalink)  
Old 3 Weeks Ago
scottn scottn is online now Forum Advisor  
VIP Member
  
 

Join Date: Jun 2009
Location: Zürich, CH
Posts: 1,057
Hi.

The shell is expanding /.../*.txt to all *.txt files and they become arguments to the script.

To stop that, you could use quotes around the argument that would otherwise be expanded:

Code:

sh sample_file.sh "/u02/app/ccalloc/dev/out/*.txt" /export/home/ccalftdv
Bits Awarded / Charged to scottn for this Post
Date User Comment Amount
3 Weeks Ago wtolentino N/A 10
  #3 (permalink)  
Old 3 Weeks Ago
wtolentino wtolentino is offline
Registered User
  
 

Join Date: Oct 2005
Posts: 33
thanks so much that works.
Reply

Bookmarks

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 05:03 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