![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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 $ 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 |
|
||||
|
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 |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|