Linux-SCO portability
Posted in 1999
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
Thanks for the suggestions, however, I'm still stuck with the environmental variable approach. Personally, I'd like to go with Art's suggestion. However, our users need to be able to pick a printer from a list. They may need to do this several times during the duration of a program. Unless someone has come up with a way to change environmental variables "on-the-fly", I cna't use it. I have found that Linux, at least my RH5.2, sets a variable OSTYPE=Linux. This variable does not exist on my SCO. So, currently I'm trying out code: if fgl_getenv("OSTYPE") = "Linux" then ... lpr -P ... else ... lp -d ... end if I did try some experimenting with uname but it generally resulted in requiring some sort of awk script. Awk is not the same on the two systems. And, I find environmental variables easier to deal with than run-time arguments. So, ... Thanks again... -- --------------------------------------------------------------------- Scott Holmes http://www.pacificnet.net/~sholmes -Run Linux- sholmes@pacificnet.net Database Programmer/Analyst Passport 4GL HTML Composer Informix 4GL, SQL --------------------------------------------------------------------- There are more things in heaven and earth, Horatio, than are dreamt of in your philosophy ---------------------------------------------------------------------
Scott Holmes wrote:
>
> Thanks for the suggestions, however, I'm still stuck with the
> environmental variable approach. Personally, I'd like to go with
> Art's suggestion. However, our users need to be able to pick a
> printer from a list. They may need to do this several times during
> the duration of a program. Unless someone has come up with a way
> to change environmental variables "on-the-fly", I cna't use it.
> I have found that Linux, at least my RH5.2, sets a variable
> OSTYPE=Linux. This variable does not exist on my SCO. So,
> currently I'm trying out code:
>
> if fgl_getenv("OSTYPE") = "Linux" then
> ... lpr -P ...
> else
> ... lp -d ...
> end if
>
> I did try some experimenting with uname but it generally resulted
> in requiring some sort of awk script. Awk is not the same on the
> two systems. And, I find environmental variables easier to deal
> with than run-time arguments. So, ...
There are two things to factor into your code:
1. You can write: START REPORT repname TO str
where str is a variable. So, you can build your list of printers
(preferably out of the database) on the fly, let the user choose
the destination, and then build up the complete command string
using "lpr -P " or "lp -d" (and, as far as I can remember, the
space is not allowed after the -d, though my memory could be
shaky; mercifully, I've not had to write an lp despooler script
these last 5 years or more).
2. As someone suggested, you could usefully build your database with
a list of platform dependencies in a single table. This works
best if the people running the I4GL program will only be running
on the machine where the database is installed. If you might have
Linux clients running an I4GL program that accesses a SCO server,
it would not be helpful to have the database record 'lp -d' when
the do the printing -- it won't work. So, it will then come back
to "how do I identify which platform the I4GL program is running
on?", and a provisional answer is to use the OSTYPE environment
variable. Note, however, that this won't help you distinguish
between Solaris and AIX and HP-UX and SCO, so you need to package
the code into a function, or even set of functions, which handle
the o/s dependencies. I'd probably use one function to identify
the o/s, and a second function to identify the printer from data
in a database table which contains canonical forms of the system
name (as returned by the first function) and specific types of
information (eg "PRINT SPOOLER") plus the value for the
combination of platform and type of information:
CREATE TABLE PlatformInfo
(
Platform CHAR(10) NOT NULL,
InfoType CHAR(20) NOT NULL,
InfoValue VARCHAR(255)
)
INSERT INTO PlatformInfo VALUES("linux", "PRINT SPOOLER", "lpr -P")
INSERT INTO PlatformInfo VALUES("sco", "PRINT SPOOLER", "lp -d ")
You can build this table up as you go..
--
Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net)
Guardian of DBD::Informix v0.60 -- see http://www.perl.com/CPAN
#include <disclaimer.h>