Operating System - HP-UX
1833870 Members
1582 Online
110063 Solutions
New Discussion

Re: Scripting Parameter Passing ???

 
SOLVED
Go to solution
MikeL_4
Super Advisor

Scripting Parameter Passing ???

I have a script that reads a file similar to:
sql toe_translate_pkb.sql
sql toe_update_pkg.sql
sql tup_$translate_pkg.sql
etc.....

I do a read of the file picking up a parameter for each filed.
i.e. read dir file

I then have to pass these
parameters onto another script, and the problem I am having is the "$" in the filename on some files is being confused for the start of another parameter. So as an end result when I pass $file onto another script the 2nd script translates that to just "tup_"

How do I get around this so the whole file name is passed along ??
3 REPLIES 3
James R. Ferguson
Acclaimed Contributor

Re: Scripting Parameter Passing ???

Hi:

Escape the dollar sign character with a backslash, as for instance:

# echo \$translate_pkg.sql

Regards!

...JRF...
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Scripting Parameter Passing ???

Here's the rule:

Let's assume that $X="Bill".

Things inside double quotes get expanded so that "xx$X" becomes "xxBill" BUT things inside single quotes remain intact. 'xx$X' remains "xx$X".
If it ain't broke, I can fix that.
Rodney Hills
Honored Contributor

Re: Scripting Parameter Passing ???

Try using

read -r dir file

"-r" will force read not to interpret the "$".

HTH

-- Rod Hills
There be dragons...