Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling shell script with an asterisk * as a parameter 1

Status
Not open for further replies.

raypru

Technical User
Apr 9, 2002
26
0
0
GB
When running a shell script I want to call another shell script and pass in a parameter representing a filename.

The structure of the filename is:

ProgramName.DatabaseName.Date.log

Whilst the ProgramName and DatabaseName are known the date is not known.

if...

ProgramName=export
DatabaseName=test
Date=any value in the format of <MonYY>

the filename parameter passed in is...

export.test.*.log

When I pass in this parameter the shell script being called substitutes the * with all sorts of strange values, whereas I want the shell to receive export.test.*.log and treat the asterisk as an asterisk.

Any ideas???
 
Quote the parameter:
'export.test.*.log'

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
This would work if my parameter was hard coded. However, the problem is that the parameter that I am passing in is an environment variable (apologies, I did not mention this in my earlier posting) ie.

FILE=export.test
FILE_EXT=log

shell.ksh ${FILE}.*.${FILE_EXT}
 
And this ?
shell.ksh "${FILE}.*.${FILE_EXT}"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Or this...
Code:
shell.ksh ${FILE}.\*.${FILE_EXT}
Hope this helps.
 
In the Korn Shell, a "[tt]set -f[/tt]" will turn off globbing so you can pass the asterisk as is. That is, it won't translate the asterisk. Like this...
Code:
set -f
shell.ksh ${FILE}.*.${FILE_EXT}
Hope this helps.
 
Thanks to PHV for your contributions. Thanks also to SamBones your suggestion set -f does the job perfectly
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top