Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am migrating from AIX to Solaris 10, but the version of /bin/sh there is so old, that our scripts does not work. Can I somehow force perl to execute commands in `` via different shell (in my case, /bin/ksh)?

I have A LOT of places with system calls, so changing them in every place is not very feasible. It would be great to find some global setting or something.

share|improve this question
if you configure your user profile to use it, i dont see why not. – Prix Aug 19 '10 at 11:36
Profile always points to /bin/ksh # echo $SHELL /bin/ksh – BarsMonster Aug 19 '10 at 11:42
Are you using these with cron or something ? that is the only way for it to actually not recognize the shell if you have changed it to something else. if that is the case the best you could do, is define the path to it within perl so it knows what to use instead. – Prix Aug 19 '10 at 12:35
up vote 5 down vote accepted

To get a POSIX environment on Solaris, you need to put the standard conformance directory (/usr/xpg6/bin, the number can be different in different Solaris versions) early in your PATH, before /usr/bin or /bin. There is a POSIX-conforming sh in there (it's ksh, in fact), and a few utilities react differently depending on $PATH even though they come in a single executable.

Either hard-code the directories:

my @xpg_dirs = glob('/usr/xpg[0-9]/bin /usr/xpg[0-9][0-9]/bin');
$ENV{PATH} = "$xpg_dirs[@xpg_dirs-1]:$ENV{PATH}" if @xpg_dirs;

or impose a standard PATH with getconf (which oddly enough isn't in the POSIX module):

$ENV{PATH} = `getconf PATH`;
share|improve this answer
Thanks, that's a perfect solution. – BarsMonster Aug 19 '10 at 12:42

See this thread on Stack Overflow.

share|improve this answer
I've updated the question. Changing whole codebase is not a nice solution. – BarsMonster Aug 19 '10 at 11:44

A thought that may help:

Can you update /bin/sh to the same version that was on your old AIX server where these previously worked. The perl behavior has not changed, just your version of /bin/sh

share|improve this answer
No, anything beyond user-level priveleges is extremely painful. :-) – BarsMonster Aug 19 '10 at 12:34

You can use shebang like this


add/repalce the above at the first line of script. It uses the /bin/ksh to execute the script.

share|improve this answer
This is alrady done, but script gets executed by sh. This is deadly strange. – BarsMonster Aug 19 '10 at 11:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.