Re: Dynamic variables within unix script fi

From: Ian Parkin <iparkin_at_lssec.bt.co.uk>
Date: 11 Jan 94 11:23:54 GMT
Message-ID: <1994Jan11.112354.16266_at_lssec.bt.co.uk>


>What do you do if the parameter you pass is text with embedded
>spaces and the number of spaces varies. For instance, the input
>might be 1 to 5 words for a 'name' parameter...

Ever heard of Unix shell quotes ??

Whilst on the subject watch out for the expansion of certain symbols by the Unix shell. Below is, I hope, a useful example :-

  • CUT-- #!/bin/sh

# Quoting with expansion - i.e. expands $. #
forename=GRAHAM
name="growler ${forename}"

# Quoting with NO expansion - i.e. $ is not expanded #
view='v$session'

sqlplus -s <user/pass> << !
select 1 normal from persons
where pers_nid_name || ' ' || pers_forename = 'growler GRAHAM';

select 1 Unix from persons
where pers_nid_name || ' ' || pers_forename = '${name}';

descr ${view}
exit
!
--CUT-- Enjoy, learn and don't be afraid of the 'man sh' Unix command

IAP Received on Tue Jan 11 1994 - 12:23:54 CET

Original text of this message