Script conversion from SCO Open Server to Red Hat
Enterpriseneeded...
Brian K. White
brian at aljex.com
Tue Jun 6 22:00:49 PDT 2006
----- Original Message -----
From: "Mike Schwartz (PC Support)" <mschw at athenet.net>
To: "'Walter Vaughan'" <wvaughan at steelerubber.com>; "'filePro'"
<filepro-list at lists.celestial.com>
Sent: Tuesday, June 06, 2006 3:54 PM
Subject: RE: Script conversion from SCO Open Server to Red Hat
Enterpriseneeded...
> OK, thanks! I was hoping it was something simple like that.
>
> Thanks to Mark and the others who have (or will) answer this. My
> immediate crisis is over...
>
> Mike Schwartz
>
>> -----Original Message-----
>> From: filepro-list-bounces at lists.celestial.com [mailto:filepro-list-
>> bounces at lists.celestial.com] On Behalf Of Walter Vaughan
>> Sent: Tuesday, June 06, 2006 2:39 PM
>> To: filePro
>> Subject: Re: Script conversion from SCO Open Server to Red Hat Enterprise
>> needed...
>>
>> Mike Schwartz wrote:
>> > I'm trying to get this old Softa script from SCO Open Server
>> (below) to
>> > run on Red Hat Enterprise Linux.
>>
>> Try running it from /bin/sh. Works just fine on FreeBSD running under
>> /bin/sh
>>
>> You should prepend #!/bin/sh at the top
I can't imagine that helped.
You should do that as a matter of course regardless of anything else, but in
this case it won't change anything by itself.
This is not the quickest & dirtiest, but I would do this:
Change all the echo's that need backslash codes, from echo to printf, and
add a trailing \n to any lines that were changed.
That would be a start towards making the script almost universally portable,
that is, portable across platforms as well as shells.
The quickest & dirtiest is:
If all you care about is making a linux version, and don't care if it breaks
on sco,
just add this line near the top:
alias echo="echo -e"
If you want the same script to work on both sco and linux, and don't mind
installing bash on sco,
then do the alias as above, and put #!/bin/bash instead of #!/bin/sh at the
top and you'll have a version that is portable across platforms but always
requires bash.
Several of the things the script does, I do differently, so I don't know
offhand if there is other syntax in there that might still be broken under
bash.
Nor do I want to test it since this script makes assumptions that are not
true on my boxes (any OS, including sco) and would be bad for me to run.
Nor do I want to fix up those assumptions since I already have something
else I wrote myself that I use instead of this.
It looks ok to me though as long as it was ok for you on your sco boxes.
Yet another alternative that is a little easier than the first (printf,
best) way, but thats still pretty portable:
Install pdksh or ksh93 or zsh, all of which have a ksh mode that should be
good enough for this.
Put "#!/bin/ksh" at the top.
Put "alias echo=print" (not printf) near the top
This way improves the chances for any other wierd syntax (besides the echo
commands) to work, since any version of ksh is closer to sco's /bin/sh than
bash is.
No matter what though, you have to fix the echo commands by one of these
ways.
Even when specifying the shell as ksh, echo still behaves differently on
different platforms and only print and printf promise to behave
consistently.
And of those two, only printf exists in bash and sco sh and freebsd sh as
well as ksh. So even though the printf way was the most work, if you do use
printf, and happen to be lucky with all the other syntax, then you can put
#!/bin/sh at the top, and have a script that works on (at least) sco, linux,
& freebsd, probably solaris, aix, & hpux too, and doesn't require you to
install anything else on any platform to make it work.
Brian K. White -- brian at aljex.com -- http://www.aljex.com/bkw/
+++++[>+++[>+++++>+++++++<<-]<-]>>+.>.+++++.+++++++.-.[>+<---]>++.
filePro BBx Linux SCO FreeBSD #callahans Satriani Filk!
More information about the Filepro-list
mailing list