I'm completely new to this and have fallen at the first hurdle.:(

I'm only playing so its not urgent.

Here is my little bit of code:

#!/bin/ksh
print Content-type: text/html
print
print '<pre style=font-family:Fixedsys>'
gtacl -c 'files $usvol1.ssdxl' |{
while read line ;do
print "${line%%=*}"
done
}
print '</pre>'

Don't worry too much about the gtacl command as that's machine specific but suffice to say the the files $usvol1.ssdxl has to be passed as is hence the single quotes (I think!).

What I'd like to do is change the code such that the $usvol1.ssdxl gets passed in as a parameter on the command line so it has to become:

gtacl -c "files $1"

The $1 gets expanded to the value of the parameter but then because the expanded value starts with a $ KSH tries to interpret as something other than a text string.

I've tried hard, but how does one get around this?

Cheers

Don

Works for me, don't you want a command like this?

$ f='$usvol1.ssdxl'
$ echo "gtacl -c 'files $f'"
gtacl -c 'files $usvol1.ssdxl'

Hi radoulov,

Thanks but, still struggling I'm afraid.
Here is new test script (my file is called cgic)

#!/bin/ksh
echo "1 is 'files $1'"
a=$1
echo "a is 'files $a'"
b="$1"
echo "b is 'files $b'"
c='$1'
echo "c is 'files $c'"

From command line invoke thus:
./cgic This.is.a.test.string

Results:
1 is 'files This.is.a.test.string'
a is 'files This.is.a.test.string'
b is 'files This.is.a.test.string'
c is 'files $1'

From command line invoke thus:
./cgic $usvol1.ssdxl

Results:
1 is 'files .ssdxl'
a is 'files .ssdxl'
b is 'files .ssdxl'
c is 'files $1'

You have to escape the $ sign:

$ cat script
#!/bin/ksh
echo "1 is 'files $1'"
a=$1
echo "a is 'files $a'"
b="$1"
echo "b is 'files $b'"
c='$1'
echo "c is 'files $c'"
$ ./script '$usvol1.ssdxl'
1 is 'files $usvol1.ssdxl'
a is 'files $usvol1.ssdxl'
b is 'files $usvol1.ssdxl'
c is 'files $1'
$ ./script \$usvol1.ssdxl
1 is 'files $usvol1.ssdxl'
a is 'files $usvol1.ssdxl'
b is 'files $usvol1.ssdxl'
c is 'files $1'

Thanks, may have a couple of other little queries re this.

Cheers
Don

This article has been dead for over six months. Start a new discussion instead.