Operating System - HP-UX
1846839 Members
7907 Online
110256 Solutions
New Discussion

I've got the subshell blues...

 
Gary Cooper_1
Esteemed Contributor

I've got the subshell blues...

HP-UX11.31, ksh

 

So, I have inherited a Korn Shell script that doesn't seem to work. Towards the end of it is the following code...

 

if [ -d CSC ]

then

        echo "Making CSC first..."

        ( cd CSC ; csc change -A pa_hpux11 ;csc make CGSVERS=8.3.3 CGSROOT=/data/development/cgs-8.3.3/current install ) || exit 1

# above on 1 line

fi

 

In very simple terms, the line " ( cd CSC ; csc change -A pa_hpux11 ;csc make CGSVERS=8.3.3 CGSROOT=/data/development/cgs-8.3.3/current install ) || exit 1" doesn't do what I expect when it's run in the script, however if I run it from the command line it works fine. Plugging echos and cats into the line, when run in the script...

cd CSC works OK

csc change -A pa_hpux11 works OK

csc make CGSVERS=8.3.3 CGSROOT=/data/development/cgs-8.3.3/current install ) doesn't

 

BTW, 'csc' is a binary executable, so I can't plug any debug commands into it, however, I have tried subsituting a noddy script for 'csc' which echos the supplied paramenters and they look OK when run from my ksh script.

 

Any ideas why that line behaves differently when run within a ksh script from when run on the command line?

 

Many thanks,

 

Gary

1 REPLY 1
Dennis Handly
Acclaimed Contributor

Re: I've got the subshell blues...

>doesn't do what I expect when it's run in the script

 

What does it do?

 

>if I run it from the command line it works fine.

 

This typically occurs because you haven't set up the right env vars.  Or you are using aliases.

(I have my ksh ENV file only set if interactive so I can't use aliases in my scripts.)

 

>I have tried substituting a noddy script for csc which echoes the supplied parameters

 

That's what I would have done.

You could try using tusc:

tusc -fp -ea -o tusc.out script-name

 

And compare with the command line version.