1

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.

Scott Pack
  • 14,907
  • 10
  • 53
  • 83
BarsMonster
  • 724
  • 4
  • 12
  • 26
  • **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

4 Answers4

5

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`;
chomp($ENV{PATH});
0

See this thread on Stack Overflow.

TCampbell
  • 2,024
  • 14
  • 14
0

You can use shebang like this

#!/bin/ksh

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

Dennis Williamson
  • 62,149
  • 16
  • 116
  • 151
Manivasagan
  • 124
  • 1
  • 5
0

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

Kevin K
  • 833
  • 1
  • 6
  • 8