[SparForte][Banner]
[Top Main Menu] Intro | Tutorials | Reference | Packages | Examples | Contributors   [Back Page]      [Next Page]  

Creating a Profile Script

When SparForte is started when a user first logs in, SparForte attempts to find and run "profile" scripts--a list of commands to set up a user's environment. By creating a profile script, a user can create variables or run programs every time they log in.

First, SparForte looks for a script called "/etc/spar_profile". This script should contain commands to be run by every user logging in.

Second, SparForte looks for a script called ".sparforte_profile" in the user's home directory. This script should contain commands specific to a particular user.

The following is a sample ".sparforte_profile" script:

-- Sample Red Hat Profile script
--
-- This is executed by the SparForte during startup.

-----------------------------------------------
-- Define Aliases

-- ls, by default, has no color.  ls_color is a script that turns
-- on the ls --color flag before running ls.

ls : constant command := "/home/ken/spar/ls_color";


-----------------------------------------------
-- Define various environment variables needed by other software

PATH := "/usr/gnat/bin:/home/ken/bin:/usr/java/bin:" & PATH;
pragma export( shell, PATH );

ASIS_DIR : string := "/usr/lib/asis";
pragma export( shell, ASIS_DIR );

CLASSPATH : string := ".:/usr/lib/jgnat.jar";
pragma export( shell, CLASSPATH );

JGNAT_LIB : string := "/usr/lib/jgnat";
pragma export( shell, JGNAT_LIB );

KDEDIR : string := "/usr";
pragma export( shell, KDEDIR );

LANG : constant string := "en_US";
pragma export( shell, LANG );

LESSOPEN : constant string := "|/usr/bin/lesspipe.sh %s";
pragma export( shell, LESSOPEN );

LS_COLORS : string := "no=00:fi=00:di=01;34:ln=01;36:pi=40;33:etc";
pragma export( shell, LS_COLORS );

QTDIR : string :="/usr/lib/qt-2.3.1";
pragma export( shell, QTDIR );

SSH_ASKPASS : constant string := "/usr/libexec/openssh/gnome-ssh-askpass";
pragma export( shell, SSH_ASKPASS );

-- export DISPLAY only if it exists
DISPLAY : string := "undefined";
pragma unchecked_import( shell, DISPLAY );
if DISPLAY /= "undefined" then
  pragma export( shell, DISPLAY );
end if;

-- disable automatic declaractions if I don't like them
pragma restriction( no_auto_declaractions );

-- declare company name, but don't export beyond shell session
company : constant string := "Compu-Global-Mega-Corp Inc.";

-- show the date and time with UNIX/Linux date command
date;

-- change my SparForte prompt
pragma prompt_script( `pwd;echo "=> ";` );

-- end of .sparforte_profile

Example: A Sample Profile Script

After the profile scripts are executed, the user sees the "=>" prompt and can being entering commands.

Study Questions

  1. What is the advantage of using "pragma import" over "unchecked_import"?
  2. What does exporting shell variables do?
 
[Right Submenu]

 Command Prompt Tutorial 1: SparForte as a Calculator

 Command Prompt Tutorial 2: Basic Shell Commands

 Command Prompt Tutorial 3: Working with Databases

 Script Tutorial 1: Basic Commands Scripts

 Script Tutorial 2: Intermediate Program Scripts

 Script Tutorial 3: Data Types

 Template Tutorial 1: Basic Templates

 Template Tutorial 2: Intermediate Templates

 GCC Tutorial: Compiling SparForte Scripts

 Debugging Tutorial - Using the SparForte Debugger

 Creating a Profile Script

 Calling SparForte from C: A Tutorial

 SparForte For PHP Developers

 SparForte Best Practices

[Back to Top] Back To Top [Small Forte Symbol]