Operating System - HP-UX
1833758 Members
2869 Online
110063 Solutions
New Discussion

Re: Sysadmin chuckle whats wrong with this code

 
SOLVED
Go to solution
Steven E. Protter
Exalted Contributor

Sysadmin chuckle whats wrong with this code

cd `dirname $0` || exit 1
casdir `pwd`

Hint: It will work from the command line. It won't work when the system is restarted.

These are the first two lines of uncommented code in this script.

10 points to the any answers that I think didn't benefit from a posted answer.

I won't identify the company involved. Lets just say it was provided by a large application company.

Is there any scenario under which this code could have been successfully tested on an HP-9000 server at start time?

Please tell me. That's worth a bunny too.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
5 REPLIES 5
Sundar_7
Honored Contributor

Re: Sysadmin chuckle whats wrong with this code

hmm..is the script name casdir and this script is included in the startup ? Am I understanding your question correctly ?
Learn What to do ,How to do and more importantly When to do ?
Steven E. Protter
Exalted Contributor

Re: Sysadmin chuckle whats wrong with this code

script name is cas

casdir is their attempt to set an environment variable for later use.

first line of code is supposed to cd to the directory the script lives in otherwise exit, because the script doesn't exist.

That in itself is a little strange because if the code is executing the script clearly exists. Still, it makes sense because if the directory doesn't exist the process can't possbily succeed.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Rodney Hills
Honored Contributor
Solution

Re: Sysadmin chuckle whats wrong with this code

If caddir `pwd` is suppose to be setting an environment variable, then should it be
casdir=`pwd`
or
. casdir `pwd` (if casdir is a script...)

We aren't talking csh here are we?

-- Rod Hills
There be dragons...
Michael Schulte zur Sur
Honored Contributor

Re: Sysadmin chuckle whats wrong with this code

SEP,

could you please be more specific about
start time and
restarted?

greetings,

Michael
Steven E. Protter
Exalted Contributor

Re: Sysadmin chuckle whats wrong with this code

Right answer with the bunny.

Whats wrong with the code is it needs a PATH variable which is not present when a system is starting.

How this code ended up in my lap, I don't know.

I'm probably going to ask Dan to nuke this thread.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com