Psion a program to transfer files between the Psion seies3 and Sun machines

Written by Tim Graves (tim.graves@uk.sun.com), This document version is time stamped 21 
June 1995 12:30 am

This document refers to version 3.27 of the suncom program and version 3.24 of the psion pro-
gram



NOTE: This program is provided AS IS, no warrantee of ANY kind is provided either by Tim 
Graves or Sun Microsystems



The psion program was written on a Sun SPARCstation running Solaris2 using the SunPRO 
SPARCWorks V2. The suncom program was written on a Sun SPARCstation using SPARC-
works to manage the code with the Psion C Software developer kit running under the SunPC 
PC emulation environment.



Copying: The same basic rules as the GNU license apply. You can copy this program as many 
times as you like and modify it in any way you like as long as you acknowledge my original 
authorship, make it obvious where you have made changes and agree to give anyone who asks 
for it the original code as you received it (or if you prefer with your modifications) for a rea-
sonable copying fee only. If you chose to provide a warrantee that's up to you but I wont pro-
vide any warrantee on these programs or ever will! So there!



Source code: The source code should be available from the same location as you got this docu-
ment. All the code for psion and suncom is held under SCCS but if you have SPARCworks you 
will probably find it easier to use that to work with the code. A SPARCworks source browser 
database may also be in the distribution. For the suncom application you will need the Psion 
Series 3 C software developers kit and some form of PC (yech) or emulation. The psion source 
is written in K & R C and compiles cleanly (I haven't dared to run it through lint) the suncom 
code generates loads of warnings (I can't find the right cast) but compiles correctly and runs 
with no problems.



This Document: This document was written using FrameMaker V4 It will probably be reada-
ble using subsequent versions of Frame but for use with earlier versions you will need do use 
the MIF (Maker Interchange Format) file enclosed. Changes from the previous version of this 
document are marked with change bars thus.



Changes overview are given in the READMEFIRST file.

It is strongly recommened that the chksumcorrect variable and filesum on command are used 
to ensure the best possible detection and correction or transmision errors

NAME

psion - a program to communicate with Psion series 3 organisers

SYNOPSYS

Psion [-var name [value]] [-i | -b] [-p | -q][-d tty_device][-r] [-log [fname]] [cmd]



This program in conjunction with the suncom application on the psion allows the transfer of 
files and a limited number of file operations. It uses a proprietary protocol and has a command 
line interface. There is a facility for automatically filtering files, a backup utility and a mecha-
nism for supporting scripts (pscmd files) to automate frequently used operations



Installation

Installation is relatively simple

1.	install the suncom application, this can be done using older versions of suncom provided 
you are using the matching version of psion and you do not try to over-write the running 
suncom file. I transferred the file down using put m:\app\suncom1.img suncom.img and 
then deleted the old version of suncom and renamed suncom1. If you do not already use 
suncom you can use xmodem or a number of other transfer mechanisms to down-load the 
application

2.	install psion. I just copied this into by bin directory. It will work well regardless of where on 
the search path it is

3.	If you are not using the default serial port (/dev/term/a) you will need to setup an alias or 
wrapper to provide the -d <your serial> parameter

4.	Optionally you can setup a .psrc.pscmd file in your home directory containing a list of com-
mands to execute every time before entering the command interpreter

Command line options

-var variable_name variable_value, sets up the variable, equivalent to setv

-r resyncs with a running suncom after a pause

-i forces interactive mode, really only prints out welcome info is automatically set if there is 
no cmd

-b forces background mode, really just suppresses welcome message, is useful in shell 
scripts, is set if there is a cmd

-v enables start-up version checking (default) should be set

-nv disables start-up version checking and should not be used except for debugging

-p forces a pause on completion (does not shutdown suncom) if operating in background 
mode, useful in shell scripts if a psion -r will be used later in the script. NOTE if the Series 
3 does an auto power off this function will not work even if the 3a is subsequently power on 
with suncom still running as something irritating seems to happen to the serial port config 
on the 3 over a power cycle.

-q forces a quit on completion (shuts down suncom), if being used in background mode, 
should be used if this is the last call to psion in a script

-d device, identifies which device to use, must be a tty (the default is /dev/term/a)

cmd, a command to run with optional arguments, forces background mode, executes the 
command, will either issue a pause or a quit (default) on completion

-log fname, causes all data sent over the serial link to be logged to fname allong with all the 
data that would be generated if the debugcall variable was set to the maximim. . If fname is 
not supplied /tmp/psion.log is used as a default. The output is similar to using the debuglink 
variable with debugcall set to 5. Be warned, this is only of any real use if you have the 
source code and is intended for debugging purposes only, the output is very large.

To use

The psion program must be started first on the Sun before starting the suncom application, the 
only exception to this is if the suncom is already running, the -r flag is in force and a previous 
psion program has exited with a pause.

Once the two programs are synchronised psion looks for a file .psrc.pscmd first in the current 
directory and then in the users $HOME, it will run the commands in this file.

Once the psrc file has been run the system will operate in command mode unless there was a 
cmd specified on the command line in which case it will execute that command and exit, either 
by pausing or quitting depending on the -q or -p flags.



Command parser

The command parser is very simple, it splits the command line up into white space separated 
arguments, no notice is taken of quotes etc, the command line must not have any white space 
preceding it as this confuses the parser.

Once the command line has been split a variable substitution phase commences (see variables 
below). The command (the first word on the line) is then checked against the list of valid com-
mands, if a matching command it found the number (not type) of arguments are then checked 
to see if they meet the number of arguments this command expects. Once a match has been 
found the command is executed.

NOTE there is currently no flow control in the command interpreter, this is not considered a 
problem as the psion program can be called multiple times using the same invocation of the 
suncom program from shell scripts by using the -r and -p flags (See later examples)



Variables

psion supports a limited concept of variables these are set using the setv, getenv and ifusetv 
commands. Once the parser has split the command line up the variable substitution checks for 
an argument of the format [var], it will then substitute this argument for the variables value.

If a variable is set but has no value the argument is set to NULL, it is not removed

It is possible (but perhaps pointless) to put a variable in place of a command, in this case the 
command will be the value of the variable

As with the shell variables are inherited by pscmd (run) files but as a new copy, a variable set 
in a pscmd file is only valid for the duration of the file and will resume its old value (if set) 
once the file exits, to setup variables without them disappearing the source command should 
be used which does not invoke a new command interpreter.

In the case of a pscmd file the arguments are mapped to argv0 (the pscmd file name) and then 
arg1.. which represent the arguments in a similar fashion to the shells, There is no equivalent 
to argc

NOTE the variable must be an argument in its own right, variables that are part of arguments 
are not recognised.



.pscmd Files

Files with the suffix .pscmd are used to hold lists of commands that will be executed by the run 
and source commands. Any command that can be issued to the interactive command inter-
preter can be used in a .pscmd file and there are a number of commands (specifically echo and 
REM) that are intended for use in pscmd files.

The run and source commands look in the directories listed in the special system variable path 
to locate the relevant file. The run and source commands are not issued with the .pscmd suffix, 
that is automatically added by the path search routine. The which command can be used to 
locate which .pscmd file will be executed.

System Variables

The following variables have special meaning to the system

path, a : separated list of locations the program will search for pscmd (run) files, similar to 
the shell path



rmcheck, if set causes the rm command to operate in a similar manner to rm -i. The system 
will ask you to confirm that you actually want to remove the file, probably should not be set 
for use with pscmd files.



autofilefilter, if set causes the automatic file filtering subsystem to operate



verbose, if set will print out information on the size and duration of file transfers and back-
ups as well as transmision good and bad block counts



dolower, if set will translate all Series 3 pathnames to lower case for gets and puts (is forced 
on during backups and rlists). This is useful as it stops uppercase file names appearing on 
the Sun.



helpfull, if set and the system discovers a problem will print out helpfull text regarding the 
nature of the problem (This is not fully implemented, currently there are only a few help 
messages)



backupnocheck, if set the backup routines don't check with you that you have closed all 
applications on the Series 3.



chksumwarn, if set after every file transfer the checksums will be compared on the sun and 
the psion and warns you if they are different



chksumcorrect, if set after every transfer the checksums will be compared on the sun and 
the psion and if different the transfer will be repeated. (If the transfer involves automatic file 
filtering this is correctly handled)



backupnodo, if set will report on what would happen in a backup / restore but will not actu-
aly do the transfer (Usefull to see if you have got the command right)



backupask, if set will ask for confirmation before performing each transfer in a backup 
operation



restoreask, if set will ask for confirmation before performing each transfer in a restore oper-
ation



procprotnocheck, if set will allow process kill / shutdown protection to be bypassed. Only 
realy usefull in scripts and should be removed as soon as used

prockillnocheck, if set will allow process kills to occur with no double check. Only realy 
usefull in scripts and should be unset as soon as the prockill is used

Debugging Variables



These are primarily intended for use during the system design phase but the output may be of 
interest if you are trying to work-out how the program works internaly

debugargs, if set prints out information from the parser

debuglink, if set prints out the data and control information sent and received across the 
serial link

debugpath, if set prints out information about the search path routines

debugrun, if set prints out information about what is happening in the pscmd file invoca-
tions

debugbackup, if set prints out some information about how the system builds up backup 
trees

debugcall [level], if set prints out very verbose information about every subroutine call. 
Each level includes the previous levels. The level does not make a lot of sense but level 1 
(the default unless specified) gives high level information about the command interpreter, 
level 2 provides argument information in the command interpreter, level 3 provides infor-
mation about the subsystems (comms libraries, backup, variables, filefiltering), level 5 pro-
vides information about the low level utility routines. If the -log command line parameter 
has been set the value of this variable cannot be changed



Filters

The system can maintain a list of filters to use when files of a certain suffix are transferred. The 
filter system only operates when the variable autofilefilter is set (it's value is irrelevant) There 
are 3 types of filter but they are all manipulated using the same commands (addfilter, delfilter, 
printfilter)

Input filters, for when a file is received by a get

Output filters, for when a file is transmitted by a put

Restore filters, to undo the work done by the output filter and to restore the file to it's origi-
nal state before the put. Note, the restore filter will normaly be the same as the input filter 
but this does not have to be the case.

Filters are set in a list which is not affected by reinvoking the command interpreter. Thus add-
ing a filter in a run file will affect transfers done outside that invocation of the command inter-
preter



NOTE there is no limit on the number of filters that can be specified as a dynamic list is used

Exclude Lists

The system maintains a list of paths to exclude when doing a backup. The exclude applies to 
the path and all files below the path, thus excluding m:\wve would also exclude 
m:\wve\fred.wve etc

The exclude list is not affected by reinvoking the command interpreter, e.g. by using the run 
command. Thus adding an exclude path in a run file will affect backups executed outside that 
invocation of the command interpreter

See the addexcl, delexcl and printexcl commands



NOTE there is no limit on the number of excludes that can be specified as a dynamic list is 
used

Commands



The following commands are available:



help [cmd] will print out the list of available commands or the help text for the cmd



get psion_path [sun_path] copies the file from the Series 3 to the Sun, if sun_path if present 
it saves the file there. otherwise the filename component from psion_path is used. The 
filename component of the psion_path can contain a * in which case all matching files on 
the Series 3 are transferred (in this case no sun_name can be given). if the variable dolower 
is set the psion_path is mapped to lower case so the resulting filename on the Sun will be 
lower case.



put psion_path [sun_name], sends the file to the Series 3, it assumes the same filename on 
the Sun as the Series 3 (excluding the path component) unless sun_name is set in which 
case it is used as the source file. The directories must exist on the Series 3. No wild cards are 
allowed. If the variable dolower is set the psion_path is mapped to lower case so the source 
filename on the Sun will also be lower case



foreach file_name pscmd, file_name is on the Sun and is assumed contain a list newline sep-
arated strings (usually of filenames from the Series 3), pscmd is executed once for each line 
with its arguments being the line



list psion_path [sun_name], lists psion_path (which may contain wild cards in the filename 
componet). If sun_name is present these are written to this file instead of the screen. Using 
list with a sun_name is usually followed by a foreach sun_name cmd



rlist psion_path [sun_name] same as list but recursivley lists all paths below psion_path. If 
sun_name is present it writes the list there.



info psion_path, prints out the size, type and if psion_path is a file the last modification date 
of psion_path



lcd sun_path, sets the current working directory on the sun to be sun_path. All the usual 
path constructions that work with the shell cd command work.



rcd psion_path, sets the current working directory on the psion to be psion_path. Note this 
follows dos conventions and that .. does not work



lpwd, prints out the current working directory on the Sun



rpwd, prints out the current working directory on the Psion



setro psion_path, sets the psion_path to be read only on the Series 3



setrw psion_path, sets the psion_path to be read write on the Series 3



mkdir psion_path, makes the directory psion_path on the Series 3



rm psion_path, removes the path (file or empty directory) on the Series 3, if the system var-
iable dolower is set it asks for conformation in the same manner as rm -i



fast, disables the screen updates on the Series 3 and displays a warning message, for file 
transfer this can result in up to 10% improvement in transfer speed. For the listing part of 
backup and rlist it can result in a 40% improvement in speed



display, reverses the fast command



run pscmdname args, executes the pscmdname (in the unix filesystem this needs the suffix 
.pscmd which is automatically appended to the pscmdname by the run command) and sets 
the arg0 to be pscmdname, arg1 ... are set according to the args specified. Like the shells the 
pscmd environment inherits any existing variables but any variables it creates or modifies 
do not affect the calling environment.



source pscmdname args, similar to run but it does not create a new command interpreter, 
thus any variables it modifies affect the calling environment, primarily used to setup varia-
bles, the .psrc file is sourced when psion starts up



which pscmdname, similar to the which command in the cshell, it locates which pscmd file 
would be used for run and source commands



! unix command, executes the unix command via the shell (used the system call)



# text, a comment, ignored by the command interpreter (though it still gets parsed and vari-
ables substituted. commonly used in pscmd files



Rem text, same as #



REM text, same as Rem and #



echo text, same as the unix echo but there is no -n option variables are substituted by the 
command interpreter before being printed, commonly used in pscmd files



setv var_name [var_value], sets the variable var_name to contain var_value for the current 
invocation of the command interpreter If var_value is not present the variable is set to "", 
the ability to set variables with no value is not really useful apart from convenience with 
system variables



unsetv var_name, removes var_name from the list of set variables for the current invoca-
tion of the command interpreter



getenv unix_var_name [psion_var_name [default_value]] gets the unix_var_name and sets 
its value and name into the current invocation of the command interpreter. If a different var-
iable name is wanted psion_var_name should be provided. If the variable is not set 
default_value can be used to provide a default



printv, prints the list of current variables and their values



ifusetv var_name value, if the var_name is not set in the current invocation set it to be 
value. If the variable is already set ignore do not set it to the new value



vars, Not really a command, just a hook for the help system text for variables



specialvars1 and specialvars2, Not really commands, just a hooks for the help system to 
describe the current variables



usage [cmd] prints out the list of commands, if cmd is supplied prints out the usage text for 
the cmd



addfilter in|out|restore suffix pscmd, sets up the automatic file filter for the given direction 
to be the pscmd for suffix. The system variable autofilehome must be set for any filters to be 
called. Note that adding a filter affects the whole system, not just the current invocation of 
the command interpreter



delfilter in|out|restore suffix, removes the filter for suffix for the given direction Note that 
deleting a filter affects the whole system, not just the current invocation of the command 
interpreter



printfilters, prints a list of the currently set filters



addexcl path, adds path to the list of paths that will be excluded by the backup and restore 
systems. Note that adding an exclude affects the whole system, not just the current invoca-
tion of the command interpreter. The format of the exclude is based on the host system. i.e. 
on the sun addexcl mymbackup/app would exclude the directory from restores 
whereas addexcl m:\app would perform the same function for backups



delexcl path, removes path from the list of files that the backup system will exclude. Note 
that adding an exclude affects the whole system, not just the current invocation of the com-
mand interpreter.



printexcl, prints the current backup exclude list



backup psion_path sun_path, recursivley copies all files and directories from the psion to 
the Sun except those excluded by the addexcl command. If the variable backupnocheck is 
not set the program will ask you to confirm that all applications on the Series 3 (apart from 
suncom of course) that use files are closed. If the variable backupask is set it will ask for 
confirmation before each individual transfer. If the variable backupnodo is set it will report 
on what would have happened but not actualy perform any transfers.

Due to different naming conventions between Unix and the psion all filenames are con-
verted to lower case and any $ signs in a filename are converted to S, thus 
M:\D$C\file.D$C becomes sun_path/dSc/file.dSc within Unix

Please note, there has been a minor change to the way backup handles its arguments. previ-
ously backup m:\wrd mydirectory/wrd would have resulted in the files actualy 
being placed in the directlry mydirectory/wrd/wrd. This change corrects this and 
now the files would be placed into mydirectory/wrd as expected.



ibackup psion_path sun_path, does an incremental backup of the psion_path comparing 
against and if nessicary updating the files in sun_path, The program allows for a 10 min. 
clock drift between the Sun and Series 3. If the variable backupnocheck is not set the pro-
gram will ask you to confirm that all applications on the Series 3 (apart from suncom of 
course) that use files are closed. If the variable restoreask is set it will ask for 
confirmation before each individual transfer. If the variable backupnodo is set it will report 
on what would have happened but not actualy perform any transfers

Due to different naming conventions between Unix and the psion all filenames are con-
verted to lower case and any $ signs in a filename are converted to S, thus 
M:\D$C\file.D$C becomes sun_path/dSc/file.dSc within Unix

Please note, there has been a minor change to the way backup handles its arguments. previ-
ously backup m:\wrd mydirectory/wrd would have resulted in the files actualy 
being placed in the directlry mydirectory/wrd/wrd. This change corrects this and 
now the files would be placed into mydirectory/wrd as expected.



restore psion_path sun_path, recursivley copies all files and directories from the sun to the 
psion except those excluded by the addexcl command. If the variable backupnocheck is not 
set the program will ask you to confirm that all applications on the Series 3 (apart from sun-
com of course) that use files are closed. If the variable restoreask is set it will ask for confir-
mation before each individual transfer. If the variable backupnodo is set it will report on 
what would have happened but not actualy perform any transfers

Please note, due to the name mangling that occurs you should only use the restore command 
on directories that were created using backup or ibackup. Also note that the mangled form 
of names should be used. I.e. to restore the M:\D$C you would have to use the command 
restore m:\d$c mybackup/dSc. 



irestore psion_path sun_path, does an incremental restore of the sun_path comparing 
against the files in psion_path. If a file on the psion is newer than the file in the backup it 
will not be restored. The program allows for a 10 min. clock drift between the Sun and 
Series 3. If the variable backupnocheck is not set the program will ask you to confirm that 
all applications on the Series 3 (apart from suncom of course) that use files are closed. If the 
variable restoreask is set it will ask for confirmation before each individual transfer. If the 
variable backupnodo is set it will report on what would have happened but not actualy per-
form any transfers

Please note, due to the name mangling that occurs you should only use the restore command 
on directories that were created using backup or ibackup. Also note that the mangled form 
of names should be used. I.e. to restore the M:\D$C you would have to use the command 
restore m:\d$c mybackup/dSc. 



pdebug on|off [psion_path], enables / disables the suncom program debugging data file 
psion_path. The default for psion_path is m:\debug.txt Warning, This can generate large 
amounts of data on the psion and is only realy intended as a debugging aid. The inclusion of 
debugging code in the suncom executable is controled by defining the C preprocessor value 
CALLDEBUG. If the suncom application has not been compiled with debugging an error 
message will be generated. To switch between debugging files the pdebug off command 
must be used before a following pdebug on command. The usage of this command requires 
atleast version 2.22 of the suncom application.

NOTE. The standerd distribution of psion and suncom are supplied without this option 
compiled in. you will need to recompile BOTH suncom and psion uncommenting the 
CALLDEBUG #define in suncom.c and the PDEBUG flag in psmain.c to get this to work



sum path [sun | psion] compute the simple check sum of path. This defaults to the 
path being on the psion unless sun is specified as the paremeter



filesum [on|off] enables / disables the file transfer subsystem second level checksum-
ming with no parameters it reports the current status



transinfo reports on the good and bad block counts held in the protocol subsystem



transreset resets the good and bad block counts held in the protocol subsystem to zero



ftransinfo reports on the good and bad block counts held in the file transfer subsystem



ftransreset resets the good and bad block counts held in the file transfer subsystem to zero



proclist [pattern [file]] lists the processes on the psion matching pattern. If no pattern is 
given all processes are listed. If the file parameter is provided the listing is sent to a file. In 
this case the pattern must be provided.



procprotect [on|off] enables the overriding of the built in sanity checks when killing proc-
esses. Unless the off argument is explicitly provided the protection is enabled and it is ena-
bled by default. procprotect will ask you to confirm that you are realy sure you want to 
make this choice. To override this double check (perhaps in .pscmd scripts) the system vari-
able procprotnocheck should be set



prockill pattern kills all processes matching pattern on the psion (See also the shutdown 
command ). THIS IS A DANGEROUS THING TO DO. There is a built in sanity check in 
that normaly system processes (they start with SYS$) the TIME process and the suncom 
process cannot be killed. (OPL processes are named SYS$PROG and the sanity check 
allows these to be killed). To override this sanity check the procprotect command can be 
used. THIS IS NOT RECOMMENDED. If the verbose variable is set the number of proc-
esses killed is reported. Theoreticaly prockill * should kill all processes that it is safe 
to do so providing that the process kill protection is in place. Before proceding with the kill 
prockill will ask you to configm that you realy want to do this. To override this question 
(perhaps in .pscmd scipts) the system variable prockillnocheck can be set.

PLEASE NOTE. ANY UNSAVED DATA CHANGES IN THE KILLED PROCESSES 
WILL BE LOST. You should not normaly be killing processes but should use the shutdown 
command. This functionality is provided so certain users can shutdown the agenda under 
program control to enable resyncs to occur.



shutdown pattern sends a shutdown message to all processes matching pattern on the 
psion. This is considerabaly more sociable than the prockill command as many processes 
will save their current data and exit gracefully. Not all prgrams written for the psion (for 
example suncom) understand the shutdown command so it may still be nessicary to use the 
prockill command in some instances. All the psion supplied programs correctly respond to 
this message as do many 3rd party programs. OPL programs may be shutdown using the 
command shutdown prog though many OPL programs will not recognise the shutdown 
message specificaly and may not save their state (The shutdown message is caught by the 
OPO runtime system. The same sanity check as the prockill command is used based on the 
procprotect mechanism. If the verbose variable is set the number of processes shutdown is 
reported. Theoreticaly shutdown * should shutdown all processes that it is safe to do so 
providing process kill protection is in place. As the shutdown command is essentialy 
benign no check is made to confirm that you realy want to shutdown the processes specified



pause, quits the psion program WITHOUT quitting suncom. used in conjunction with the -
r option for restart in shell scripts



quit, quits psion and instructs suncom to quit

Still to do

Provide a better checksumming algorythym. The psion developers kit allows the use of crc bit 
I cant get the same results with the same data on the sun and the psion. Also the crc stuff does 
not seem to be position dependent

Integrate the psion command into a tcl library. This would be reasonabely easy to do but would 
require a majore internal rewrite to get all the command names into the formats expected by 
tcl. This is not a priority though as the psion command can be effectivly used inside shell 
scripts by using the -r and -p flags (See the later example)

Failing tcl I plan to work on the command interpreter. I cant think of any more functionality 
that needs to go in in terms of commande (Ideas are welcome though)

Example .pscmd file with comments

The following is an example psrc.pscmd file it is taken from my home directory

# setup the variables from unix

getenv HOME

getenv SHELL

getenv HOST

getenv LOGNAME

# try to locate the mail server, if it does not exist use the 
already established HOST variable

getenv MAILSERVER MAILSERVER [HOST]

getenv PRINTER PRINTER lp

# do the welcome type stuff

# LOGNAME is already initialises as part of my login procedure 
and via the getenv

echo Welcome to the Psion Program [LOGNAME]

# setup the search path

setv path .:./pscmd:/home/tim/bin:/home/tim/bin/pscmd:../
pscmd:..

# I prefer to know transfer speed information etc so set verbose

setv verbose TRUE

# I want automatic file filtering so set autofilefilter

setv autofilefilter

# add the input / output filters

addfilter in txt gettxt1

addfilter out txt puttxt1

addfilter restore txt gettxt1

# I have a real problem handling the upper / lower vase changes 
so set dolower

# to force all filenames to be lower-class unless I specify an 
uppercase name deliberately

setv dolower

# having accidentally deleted a file I want a confirmation 
check

setv rmcheck

# When I do backups I don't really need the sound 3a directory 
I can easily recreate

# the sound files is required

addexcl m:\wve

# set a variable for my backup directory

setv PSIONBACKUP psion/incremental_backup

#and define the default partition for the backup

setv BACKUPDEFAULT m:

# I want my backups to run automatically so set backupnocheck

setv backupnocheck

# END of .psrc.pscmd, the command interpreter will take over 
here

.pscmd example

The following is an example of a .pscmd file to handle my calendar manager and to keep the 
two in sync. Note that I can use unix shell variables for unix commands as these are handled by 
the unix shell (csh in my case)

# This file gets my calendar from the psion, runs the merge pro-
gram and 

# puts the file back

# setup some variables unless they are already set from else-
where

ifusetv SUNAGNFILE new.agn

ifusetv AGNNAME sunco.agn

ifusetv AGNPATH m:\agn\sunco.agn

# turn of verbose for this .pscmd file, this wont affect the 
rest of the system

unsetv verbose

# get the CM config file from my server

# use unix to do this and say what we are doing

echo Getting the Sun CM file

! rcp $MAILSERVER:/var/spool/calendar/callog.$USER

# shut the agends down on the psion

# dont want to be asked to confirm this one

setv prockillnocheck

prockill agenda

# want to make sure I dont do any other accidental kills

unsetv prockillnocheck

# get the psion file

get [AGNPATH]

# call the cmmerge to get the new file, NOTE this is a sun 
internal command

! cmmerge callog.$USER [AGNNAME]

# put the new file back

echo Transferring the updated agenda file

put [AGNPATH] [SUNAGNFILE]

# some minor tidying up, the callog file is mode 400 so reset 
the mode and remove it

! chmod 666 callog.$USER

! rm callog.$USER [SUNAGNFILE] [AGNNAME]

# END OF DOAGNMERGE



Another .pscmd example

This .pscmd file does an incremental backup for me

# dobackup pscmd file

# PSIONBACKUP and BACKUPDEFAULT should already be set by the 
.psrc 

# but if they are not set them anyway

ifusetv PSIONBACKUP psion

ifusetv BACKUPDEFAULT m:

# I want to know what is happening so turn verbose on

setv verbose

# I want this to be fast so disable the psion display

fast

# do the incremental backup

ibackup [BACKUPDEFAULT] [PSIONBACKUP]

# that's done, re-enable the display on the psion

display

# ALL done return to the interpreter

# END OF dobackup



An example of using psion from the cshell

The following shows how the psion program can be used within the cshell, it really does noth-
ing that a .pscmd file could not do with some automatic file filtering and foreach commands but 
may be of interest

#! /bin/csh -f

# this file reads a list of rtf files from the m:\wrd directory

# copies them over and runs the interleaf rtf to iaf filter 

# and then installs them in my interleaf desktop

set RTFFILT /interleaf/bin/rtftoiaf

# use psion to get a list of the rtf files note we have to 
escape the \ for the shell

psion -b -p list m:\\wrd\\\*.rtf /tmp/rtflist

# now get each file into a temp dir

mkdir /tmp/rtf

cd /tmp/rtf

psion -r -p foreach /tmp/rtflist get

# delete the rtf files on the psion

psion -r -p foreach /tmp/rtflist rm

# now filter each file, use the csh foreach

foreach i (/tmp/rtf/*)

$RTFFILE < $i > $i.doc

mv $i.doc ~/desktop

end

# now delete the temp files the

cd

rm /tmp/rtflist

rm -rf /tmp/rtf

# now close down suncom, may as well do the echo from the psion 
prog

psion -r -q echo rtf files transferred.Done



Porting

I have written the code as cleanly as I can, it will compile clean on Solaris 2 (and I suspect on 
any SVR4 based machine) To port to Solaris 1 or other BSD based systems the time compari-
son routine (backupmodified) in the backup section of the code (psbackup.c) has a #ifndef 
SVR4. this section of the code may need changing for SCO or other flavours of Unix to reflect 
the posibly different time representation in the stat structure
