Passing a wildcard in a variable


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Passing a wildcard in a variable
# 1  
Old 05-24-2011
Passing a wildcard in a variable

Hi There

I am new to scripting and require some assistance please.

I am trying to define a variable with a wildcard in a shell script (.ksh) that will be run on AIX 5300-10.

The variable I am trying is:
Code:
FILES=LLA_*.CSV

When I run the following section of the script:
Code:
scp SVC_RSIT@$SOURCE_SERV:"l:$SOURCE_LOCATION\\$FILES" $TEMP

I am receiving the following error:

Code:
scp: l:FTP\Incoming\IPU\Prod\Finance\LLA_*.CSV: No such file or directory
Files not found in FTP\Incoming\IPU\Prod\Finance

I can see the file in the directory, and it has the correct permissions set so there should be no issue discovering or moving it. The wildcard is obviously not being expanded which is causing the problem.

This script will move files from a windows server running the RSIT application to a UNIX box. Could you please advise if it is possible to use a wildcard in a variable, and if it is, how I would go about it?
# 2  
Old 05-24-2011
You have to force an evaluation on it. There can be several ways... the portable way in bourne shells is with the "eval" command.

However, expansion can fill up the command line buffer limit.... so it might be better to look at how to use "find" and "xargs" if at all possible. That way you can also avoid the use of "eval" which could introduce other side effects. With that said, unless you're using SSH keys above, you'd have to type in your password for every scp call (xargs will make as many calls as needed to get handle a large list of incoming arguments).
# 3  
Old 05-24-2011
Thanks cjcox

I have resolved the issue. Thanks again for your help.

Last edited by jimbojames; 05-24-2011 at 10:22 PM.. Reason: Resolved
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Passing variable as input & storing output in other variable

I have a below syntax its working fine... var12=$(ps -ef | grep apache | awk '{print $2,$4}') Im getting expected output as below: printf "%b\n" "${VAR12}" dell 123 dell 456 dell 457 Now I wrote a while loop.. the output of VAR12 should be passed as input parameters to while loop and results... (5 Replies)
Discussion started by: sam@sam
5 Replies

2. Shell Programming and Scripting

Passing dynamic variable within another variable.

I have a small program which needs to pass variable dynamically to form the name of a second variable whose value wil be passed on to a third variable. ***************** Program Start ****************** LOC1=/loc1 PAT1IN=/loc2 PAT2IN=/loc3 if ; then for fpattern in `cat... (5 Replies)
Discussion started by: Cyril Jos
5 Replies

3. Shell Programming and Scripting

Passing variable with *

Hi Folks, I would like to pass a variable with a wild card in an argument. My script works if I don't use a wildcard but fails when I use *. I want to use the script like: scriptname -F <filename*> @ i = 0 while ($i <= ${#argv}) switch ($argv) case -F: set j = `echo $i +1... (2 Replies)
Discussion started by: dixits
2 Replies

4. Shell Programming and Scripting

Passing wildcard parameters to find via a variable

I have a script to fix permissions which is made up of blocks like: FS_ROOT=/home/shared/Photos FS_EXCLUDE=( \( -path */.webviews -o -path */.thumbnails \) -prune -o ) find $FS_ROOT ${FS_EXCLUDE} -type d -not -perm 2770 -exec chmod 2770 "{}" \; That fragment works as expected, but no matter... (3 Replies)
Discussion started by: mij
3 Replies

5. Shell Programming and Scripting

ls wildcard output to a variable

I am new to shell programming, i have a requierement to assign a file name into a variable. for ex: the file name are below 603_2009_09_24_34.csv 702_2009_10_25_10.csv for ex: i need to get the file 603_2009_09_24_34.csv but first 3 didgits are fixed but rest of the digits are not below is... (3 Replies)
Discussion started by: Devendar
3 Replies

6. Shell Programming and Scripting

How to maintain wildcard array variable

Hi all, I have this scenario where:- The file that I want to save its name into array df is my.08120323.trx which is located in the dir as below: $ pwd /u01/abc/def/SRC_datafiles $ ls *trx my.08120323.trx $ df=*"trx" ##keeping the filename my.08120323.trx into df $... (2 Replies)
Discussion started by: luna_soleil
2 Replies

7. Shell Programming and Scripting

passing a variable inside another variable.

Any help would be great. I know this is a dumb way of doing this, but I would like to know if there is a solution doing it this way. I'm very new at this and I'd like to learn more. Thanks! :D:D count=0 while ; do echo "enter your name" read name_$count let count=count+1 done ... (2 Replies)
Discussion started by: reconflux
2 Replies

8. UNIX for Dummies Questions & Answers

passing a variable inside a variable to a function

I would like to know how to pass a variable inside a variable to a function. sample code below -------------- for x in 1 9 do check_null $C$x ##call function to check if the value is null if then echo "line number:$var_cnt,... (2 Replies)
Discussion started by: KingVikram
2 Replies

9. UNIX for Dummies Questions & Answers

Variable passing

Hi, If a script A(Parent) is running and script B(child) is run from script A, will the variables in script A be past to script B? Will the variables exist only for the duration of running the script? Thank you (2 Replies)
Discussion started by: whugo
2 Replies

10. UNIX for Dummies Questions & Answers

Find wildcard .shtml files in wildcard directories and removing them- How's it done?

I'm trying to figure out how to build a small shell script that will find old .shtml files in every /tgp/ directory on the server and delete them if they are older than 10 days... The structure of the paths are like this: /home/domains/www.domain2.com/tgp/ /home/domains/www.domain3.com/tgp/... (1 Reply)
Discussion started by: Neko
1 Replies
Login or Register to Ask a Question