Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

`basename $0` - different in SCO and AIX? 1

Status
Not open for further replies.

aluris

Programmer
Jan 15, 2003
9
0
0
US
Hi,
1)Migrating from AIX 4.3.2 to SCO 5.X..
2)Code has the statement
x=`basename $0 .sh`....
3) Under AIX environment, irrespective of the calling module, the above statement returns "script name without the .sh"..
Whereas in SCO 5.X, the same statement returns
"the modulename without the .sh"..
For example,
Main script name is "sesame.sh" and in "sesame.sh" there are modules like "ReadInFile" , "UpdateTheTable" etc.,
Under AIX, when the basename statement shown above is used, value returned is "sesame" - always;
Whereas in SCO, value returned by the same statement depends on from which module the statement is executed...the value returned could be "ReadInFile" or "UpdateTheTable" etc..

Why the difference? How to solve? Please!
 
One workaround would be to have at the beginning of the main script:

[tt]SCRIPTNAME="$0"[/tt]

And change the subsequent references to $0 to $SCRIPTNAME}. Annihilannic.
 
Thanks!
Already did that. Works fine.
But, where could be the difference? Can a simple system
level change take care of this problem? That way
maintenance would be easier!
Please share your thoughts...

 
I doubt it; I presume it's just due to the different heritage of AIX and SCO OpenServer.

I guess you could write your own basename and put it in /bin but I think that would be overkill. Annihilannic.
 
Thanks for reply. Appreciate your help and time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top