# How to run MS FoxPro Unix on FreeBSD



## michaelrmgreen (Jan 17, 2011)

This text is excerpted from my notes on how to make a FreeBSD system to support MS FoxPro 2.6 for Unix. This is version 2. Last revision date 17 January 2011.

Based on FreeBSD version 7.2.

1. Prepare the system
2. Install FreeBSD
3. Post installation configuration
3.1. Mtools
3.2. Terminfo
3.3. ibcs2
3.4. Printing
3.5. Samba
3.6. Telnet
3.7. AutoIt
4. Move the FoxPro files
5. Transfer the data
5.1. Add the users
6. Set up printing
7. Misc.
8. Shell scripts

1. Prepare the system.

Section snipped to save space.


2. Install FreeBSD.

Snipped to save space.

3. Post installation configuration.

3.1 mtools
The mtools packages is a handy utility to interact with dos filesystems without having to mount and unmount them.
Install mtools:

```
# pkg_add -r mtools
```
or use sysinstall

```
# sysinstall -> Configure -> Packages -> CD/DVD -> emulators -> mtools.
```
Edit the configuration file /usr/local/etc/mtools.conf . Add the line

```
drive u: file="/dev/da0s1"
```

This should make a USB stick accessible as u:. A restart MAY be necessary to get this to work. Note that USB drive use the SCSI subsystem so the names are /dev/dans1 where n is the next available drive. If you have an SCSI hard drive the number of the USB stick will be 1 (ie /dev/da1s1).

3.2 Terminfo database
Compile the port:

```
# cd /usr/src/lib/ncurses
# make
# make  install
```
Possible problems : the 'built-in' port doesn't create tic so the  terminfo files aren't created. Use csup to update the ports tree:

```
# csup -L 2 -h cvsup.FreeBSD.org /usr/share/examples/cvsup/ports-supfile
```
Now compile the ncurses port.

```
# cd /usr/ports/devel/ncurses
```
Edit Makefile replacing '--with-hashed-db' with '--without-hashed-db' then compile : 

```
# make install clean
```

The FreeBSD version of tic (terminfo compiler) puts the terminfo files in either /usr/share/terminfo or /usr/local/share/misc (the latter is the ports version -check). OpenServer/OpenDesktop/Xenix programs expect to find the terminfo dir at /ust/lib/terminfo. Link this directory to /usr/lib/terminfo so OpenServer programs can find it.

```
# ln -sf /usr/share/terminfo /usr/lib/terminfo
```
or

```
# ln -sf /usr/local/share/misc/terminfo /usr/lib/terminfo
```



3.3 ibcs2
ibcs2 is the emulation layer which allows binaries targeted on other systems, especially SCO systems, to run on FBSD.

Edit /boot/loader.conf  Add lines

```
ibcs2_load=â€YESâ€
ibcs2_coff_load=â€YESâ€
```
After a reboot kldstat should show ibcs2.ko and ibcs2_coff.ko loaded.
An error message from foxpro.pr about unexpected ')' or similar indicates ibcs2 isn't loaded.

Create these directories:

```
# mkdir /usr/compat/ibcs2
# mkdir /usr/compat/ibcs2/dev
```
Create these links

```
# cd /usr/compat/ibcs2/dev
# ln -sf /dev/null X0R (ecs nought arr)
# ln -sf socksys nfsd
# ln -sf /dev/null socksys
```
Make an empty file called null

```
# touch null
```

3.4 Printing

Section sniped to save space.

3.5 Samba

Section snipped to save space.

3.6 Telnet
Download and install PuttyTel on the client PCs. Put it in a suitable folder, say d:\usr\software\puttytel. Start PuttyTel and change 'backspace' to Control-H. In 'Terminal' - 'Features' enable 'Disable application keypad mode'. In 'Window' set 'Rows' to 25. In 'Windows' - 'Translation' set character set to CP437. Now in 'Session' click on 'Default Settings' then click 'Save'.

3.7 AutoIt
Download and install AutoIt. Create an AutoIt script called parkrow.aut. Add these lines


```
sleep(1000)
run("d:/software/puttytel/puttytel parkrow3")
sleep(2000)
send("noggin{enter}")
sleep(3000)
send("thor{enter}")
sleep(1000)
send("cd /usr/data/usr/parkrow{enter}")
sleep(1000)
send("foxpro -eiot +pc prstart" ,1)
send("{enter}")
;
; ,1 on end of send command above sends 'raw'
; avoiding the capitalisation of 'p'
;
sleep(1000)
send("av")
```
4. Move the FoxPro files

On the current system create a tar file

```
# cd /usr/local/lib/foxpro 
# tar -cvf /tmp/fox.tar *
```
Move to a USB stick with mtools

```
# mcopy /tmp/fox.tar u:
```
On the new system create the directory

```
# mkdir /usr/local/lib/foxpro
```
Copy the files

```
# cd /usr/local/lib/foxpro 
# mcopy u:fox.tar .
```
Untar the files
# tar -xvf fox.tar [Enter]

Create a 'front-end' for foxpro


```
#! /bin/sh
# this file /usr/local/bin/foxpro
umask 000
PROGDIR=/usr/local/lib/foxpro
PATH=$PROGDIR:$PATH
export PATH
# The OpenServer value of TZ in the UK is this :
TZ=GMT0BST,M3.5.0/1,M10.5.0/1
export TZ
exec $PROGDIR/foxpro.pr "$@"
```

Save and then make executable

```
# chmod a+x /usr/local/bin/foxpro
```
5. Transfer the data
Either use tar and a USB stick, or, better still, use the backup file to prove the backup process works! Download the backup files nprimary.tar and nupdate.tar and copy to the root dir of a USB stick. Tranfer to /tmp:

```
# cd /tmp
# mcopy u:*.tar .
```
Now restore the tar files:

```
# cd / 
# tar -xvf /tmp/nprimary.tar
# tar -xvf /tmp/nupdate.tar
```

Enable writing to the data directories

```
# cd /usr/data/usr
# chmod a+rwx parkrow
# chmod a+rwx accounts
```

Enable writing to data and program files

```
# cd /usr/data
# chmod -R a+rw *
```



5.1 Add the users
Add users: recep1 and so on. Make sure they are invited into group 'wheel'.
<More snipping to save space>

Change the owner, group and perms for the data and program files: 

```
# chown recep1:wheel *
# chmod a+rw *
```
Change the directory to writable

```
# cd /usr/data/usr
# chmod a+w parkrow
```

Make a dir for the backup files

```
# mkdir /usr/data/backup
# cd /usr/data
# chmod a+w backup
```

The console cannot be used directly, but, after the network is configured, a telnet session can be used for access from the console:

```
$ telnet localhost
user (console):console
password: consolepass
$ FOXTERM=ansifox; export FOXTERM
$ foxpro -eiot +pc prstart
```

Possible issue: Telnet not starting. Check both /etc/rc.conf for 	inetd_enable="YES" and /etc/inetd.conf for telnet line enabled.

6. Set up printing
Snipped to save space

7. Misc.
snipped to save space

8. Shell Scripts
This section contains shell script versions of the previous instructions, cut out-'n-keep!

Snipped to save space. 

If anybody is the slightest bit interested send me an personal message and I'll send you the unexpurgated version. Further to that, I have a previous version which tackles using serial terminals. You only have to ask.


----------



## wblock@ (Jan 17, 2011)

Interesting.  Why telnet?  Could you use regular PuTTY and connect via ssh?


----------



## michaelrmgreen (Jan 17, 2011)

@wblock
Just a quirk of (my) history. I'm sure ssh works just as well, but I haven't tried it yet. Are you a FoxPro unix user or do you use ibcs2 for anything?


----------



## wblock@ (Jan 17, 2011)

michaelrmgreen said:
			
		

> @wblock
> Just a quirk of (my) history. I'm sure ssh works just as well, but I haven't tried it yet. Are you a FoxPro unix user or do you use ibcs2 for anything?



I used Foxpro all the way from DOS (2.0 or 2.1?, FP that is, not DOS!) to VFP 6 to VFP 9.  Never tried the Unix version, but it's nice to have the option.  Still know of some users running FP 2.6 from a FreeBSD Samba server.


----------



## michaelrmgreen (Jan 17, 2011)

MS FoxPro Unix is awesome. I used it for years on steam terminals. There is NO direct replacement. Its such a shame that MS couldn't maintain it.


----------

