Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#351964 - 03/05/2012 11:51 Bizarre C-Shell Script Problem
Tim
veteran

Registered: 25/04/2000
Posts: 1525
Loc: Arizona
This is just baffling. As part of a software installation package, I have a series of C-Shell scripts. The main script calls the rest.

The issue I am having is that the main script isn't calling the embedded one. The call looks like this:

Code:
if (-e ${media}/bin/check_os) then
        echo "${media}/bin/check_os exists.  Calling check_os"
        ${media}/bin/check_os
        echo "Outside check_os.  Status is $(status)"
        if ($status == 1) then
                echo "check_os status = 1"
                goto fatal-fixable-exit


The variable media is defined correctly and the echo before the call looks good. Then, inside the check_os script, I have an echo right after #!/bin/csh that never gets called, so the status variable never gets set. Running the command /media/dvd/bin/check_os ($media is /media/dvd in the above script) from the prompt works fine.

I've never seen this problem before, and it has worked on several machines previously. Anybody have a clue what is hosed up?

Top
#351965 - 03/05/2012 12:42 Re: Bizarre C-Shell Script Problem [Re: Tim]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
Originally Posted By: Tim
I have a series of C-Shell scripts.

Well, there's your problem.

wink

Does /bin/csh exist? Some systems will only have a /usr/bin/csh. If it doesn't exist, then change your '#!/bin/csh' line in the new script.
_________________________
Bitt Faulk

Top
#351966 - 03/05/2012 12:51 Re: Bizarre C-Shell Script Problem [Re: wfaulk]
Tim
veteran

Registered: 25/04/2000
Posts: 1525
Loc: Arizona
Originally Posted By: wfaulk
Does /bin/csh exist? Some systems will only have a /usr/bin/csh.

It does. Since this has worked a zillion times previously, albiet on clean OS installs, I'm at the point where I just back up the machine and nuke the site from orbit. It's the only way to be sure.

Top
#351967 - 03/05/2012 12:53 Re: Bizarre C-Shell Script Problem [Re: Tim]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
Then run it via strace and see where it's going wrong.
_________________________
Bitt Faulk

Top
#351968 - 03/05/2012 15:01 Re: Bizarre C-Shell Script Problem [Re: Tim]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14493
Loc: Canada
Originally Posted By: Tim
Originally Posted By: wfaulk
Does /bin/csh exist? Some systems will only have a /usr/bin/csh.

It does. Since this has worked a zillion times previously, albiet on clean OS installs, I'm at the point where I just back up the machine and nuke the site from orbit. It's the only way to be sure.

So the only other explanation is that the second script is not in the search $PATH provided in the first script.

Except you've hardcoded the path.

Ugh. /bin/sh anyone?


Edited by mlord (03/05/2012 15:01)

Top
#351969 - 03/05/2012 15:04 Re: Bizarre C-Shell Script Problem [Re: Tim]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14493
Loc: Canada
Originally Posted By: Tim
This is just baffling. As part of a software installation package, I have a series of C-Shell scripts. The main script calls the rest.

The issue I am having is that the main script isn't calling the embedded one. The call looks like this:

Code:
if (-e ${media}/bin/check_os) then
        echo "${media}/bin/check_os exists.  Calling check_os"
        ${media}/bin/check_os
        echo "Outside check_os.  Status is $(status)"
        if ($status == 1) then
                echo "check_os status = 1"
                goto fatal-fixable-exit


The variable media is defined correctly and the echo before the call looks good. Then, inside the check_os script, I have an echo right after #!/bin/csh that never gets called, so the status variable never gets set.


I gave up on csh decades ago: remind me again how "status" gets set?
As the result of executing a command?
Like the "echo" command on the line before the status check? wink

Top
#351970 - 03/05/2012 15:10 Re: Bizarre C-Shell Script Problem [Re: mlord]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14493
Loc: Canada
Stick a "set -x" line at the top of each script, just after the "#!" lines. This will enable line-by-line tracing of execution.

Top
#351972 - 03/05/2012 16:35 Re: Bizarre C-Shell Script Problem [Re: mlord]
Tim
veteran

Registered: 25/04/2000
Posts: 1525
Loc: Arizona
I'm not sure what the issue was, after dorking around with it for a few hours I thought it would be quicker to just start from scratch. I reinstalled the base system it was expecting (RedHat 5.5, but I use CentOS) and it magically started making the calls again.

The only thing I can figure is that since this was a machine I was using for other purposes, I was keeping it updated. One of the patches since that release and now must have mucked with something that the script was using.

Like I said, completely bizarre. Thanks for the suggestions on strace (which I completely forgot about) and set -x (which I never even knew about).

Top