Tech Tips

 


 

Perl

Perl Design Patterns

Install

All Platforms

 

Install Perl

Perl can be obtained via links on the CPAN web site

For Windows, I recommend obtaining Perl directly from ActiveState

 


 

 

Command Line Perl

Multiple Files

Search And Replace

pipe

xargs

All Platforms

 

Fun with Command Line Perl

CAUTION: Since it copies, modifies, then copies back, it can work around write permissions. i.e. if a file is not writeable, I can still modify it with cmd line perl. So, allways backup files before using command line perl. Also, if you are modifying multiple files at once, try your one-liner on a copy of a single file first to make sure it does what you intend.

To determine if you have perl in a shell or command window, type

perl -v

If you don't have it, Install Perl 

Backup the directory or folder in which you are going to work, e.g.

cp -pr target_dir backup_dir 

Replace 'Tom' with 'Thomas' wherever it appears in all html files in the current directory

perl -pi -e 's#Tom#Thomas#g' *.html

Replace 'tom', 'TOM', 'Tom', etc. (case insensitive) with 'Thomas' wherever it appears in all html files in the current directory

perl -pi -e 's#Tom#Thomas#gi' *.html
            

To make an entire file UPPERCASE:

perl -pi -e 's#(.)#\U$1\E#g' table.html
            

Or lowercase:

perl -pi -e 's#(.)#\L$1\E#g' table.html

If you have, for example, an HTML file:

1. saved in some mode other than 'unix line breaks'

2. with all the text on one line when you 'vi' it...

2. and 'grep', command line perl, etc. DO NOT WORK...

3. 'wc -l <filename>' yields '0' lines despite there being text in the file...

It is likely that you have a file with NO hard returns at all, so grep, etc. do not know how to deal with them. Fortunately, command line perl can. This command puts a hard return at the end of the line so you can deal with it:

wc -l *.htm* | grep " 0 " | xargs perl -pi -e 's#$#\n#'

This command replaces UNIX-innappropriate CTRL-M line breaks with UNIX-happy hard returns. You type in CTRL-M and other control characters by 'escaping' them with 'CTRL-v'. So ^M is created by this sequence: 'CTRL-V, CTRL-M'

perl -pi -e 's#^M#\n#g' *.htm*  

 


 

 

Web Browser

Web Server

HTTP

META Tags

Expires

All Platforms

 

Expiring HTML Pages

(Copyright © 1997 Netscape Communications Corporation)

The "official" way to force a browser to reload a page from the server every time you visit it is to use an HTTP "Expires" header line, like this:

Expires: Tue, 25 Apr 1995 09:30:00 -0700

Note that this is the same sort of "Expires" line that appears in news messages, and that it's not in ctime format (that is, the date here is in a different format than you get from the Unix "date" command). In a CGI script, you can just echo this out after you send the

"Content-type:" line.

In an HTML file, you can put this in a <META> tag at the top of your file, and some browsers will pay attention to this:

<META HTTP-EQUIV="Expires" CONTENT="Tue, 25 Apr 1995 09:30:00 -0700">

The expiration time should generally be set to the current time (which is easy to specify from a CGI script) or a few minutes in the future.

Times in the past might also work, but some browsers might complain about this. If the browser loads a page whose expiration date is before a few minutes from now, then it shouldn't cache the page at all. (The reason there's a leeway of a few minutes is to compensate for the server's clock possibly being a little bit fast.)

 

 


 

 

HTTP

Web Browser

Web Server

Perl

Capture HTTP Request

 

Capturing an HTTP Request
         

If you are a web developer who would like to see just what the HTTP headers your HTML Browser is sending to your WWW Server, this is a short perl script that will print the request to standard out. Just set "$this_host" and "$port" for your environment and run the script. While it is running, it will print HTTP requests you make via a web client. Usually, I use this to debug problems with CGI or NSAPI scripts.

         
#!/usr/bin/perl
                   
use Socket;
            
$this_host = "test.ibfd.org";
$port = 2003;
            
# Initialize C structure
$server_addr =(gethostbyname($this_host))[4];
$server_struct = pack("S n a4 x8", AF_INET,$port, $server_addr);
            
# Set up socket
$proto = (getprotobyname("tcp"))[2];
socket(SOCK, PF_INET, SOCK_STREAM,$proto)|| die "Failed to initialize socket:$!\n";
            
# Bind to address/port and set up pending queue
setsockopt(SOCK, SOL_SOCKET, SO_REUSEADDR, 1) || die "setsockopt() failed: $!\n";
bind(SOCK, $server_struct) || die "bind() failed: $!\n";
listen(SOCK, SOMAXCONN) || die "listen() failed: $!\n";
            
# Deal with requests
for (;;) {
     # Grab next pending request
     $remote_host = accept(NEWSOCK, SOCK);
     die "accept() error: $!\n" unless ($remote_host);
            
     # Read and print client request
     while (<NEWSOCK>) { print; }
            
     # All done
     close(NEWSOCK);
}
            

 


 

 

find

dos2unix

cp

xargs

pipe

Command Line Perl

Unix

 

Fun with find

To run dos2unix <filename> <filename> on each file ending in .xom in this directory and sub directories:

find . \( -name "*.xom" \) -exec dos2unix {} {} \;

You can use any find options instead of simply find by name:

find . \( -type f \) -exec dos2unix {} {} \;

To copy all python files in /tmp and below to this directory:

find /tmp \( -name "*.PY" \) -exec cp {} . \;

Recursive grep for a string in all text files:

find . \( -name "*.txt" \) -exec grep "APP_NJ" {} \;

Take dumped '.dat' files from a lynx traversal (see lynx) and change the file names to '.html' trimming off extra junk This only works for up to 99 filesThe below example should be executed as one line:

find . -name "*.dat" -print | perl -ne 'chop; $old=$_; $new=$old; $new =~ s#lnk.*(\d\d\.)dat#$1html#; system("mv $old $new");' 

Pipe to command line perl via xargs

find . -name "*.htm*" -print | xargs perl -pi -e 's#trowe#god#g'

Find and delete files which have not been accessed today

find . -atime +1  -exec rm -f {} \; 

Find and copy all perl scripts under my home dir to here

find ~ -name "*.pl" -print | xargs -i -t cp {} .
or on MacOS X:
find ~ -name "*.pl" -print | xargs -I {} cp {} .

Find some arbitrary files and create a tar archive file out of them:

touch archive.tar
find . -name "*.shtml" | xargs tar uvf archive.tar 

 


 

 

at

cron

Unix

 

Create a pseudo cron job which runs in your own shell

Create a file with a list of commands like these:

# my.daily runs every day
at now tomorrow < /usr/home/trowe/bin/my.daily
/bin/xv -root /opt/map.gif -ge 1365x1065 -sm -ni -quit
       

Make it executable:

chmod a+x my.daily

Start your at job, say, tomorow at 5am (it will run every day at this time)

at 5:00amjul25

Enter the name of an executable list of commands you want run daily

/usr/home/trowe/bin/my.daily

Then to end it type:

CTRL-D

 


 

 

Special Characters

Unix

 

Bold and Underlined Text

This file contains special characters which create bold and underlined text in the unix vt100 style window. Save this file to get the characters (do not copy & paste)

 

 


 

 

Clearcase

Unix

 

Clearcase

To see a list of versions:

ct lsvtree <file>

To remove a version, use the file-path from lsvtree as argument to:

ct rmver <file-path>

To check in all checked out files in a view

ct lsco -cview -avobs -short | xargs cleartool ci -nc

Print a merge of a given view (st4465) into the current view

ct findmerge -avobs -fver /main/st4465/LATEST -print

Merge a given view (st4465) into the current view

ct findmerge -avobs -fver /main/st4465/LATEST -merge

 


 

 

cron

crontab

Unix

 

cron

I like to put a commented line at the top of my crontab file which helps remindme of the syntax. e.g.

# minute hour day-of-month month weekday [absolute path to cmd]
#
# The cron job below will run 'cleanup.pl' at 5:01 am daily 
# with output and errors disgarded
1 5 * * * /usr/local/bin/cleanup.pl /etc > /dev/null 2>&1

 


 

 

XML DTD

Validation

Java

All Platforms

 

XML DTD Validation

To validate a DTD and an xml file:

1. Download and install Sun's msv

2. Run it:

java -jar msv.jar general_search_results.dtd general.xml

 


 

 

emacs

viper

Unix

 

emacs Viper Mode 

To enter vi emulation mode, do:

M-x viper-mode
M-x vi-mode
M-x vip-mode

The first, for example means

1. hold down 'ESC', hit 'x'

2. type 'viper-mode'

 

To change the font colors:
1. Go to Help::Customize::Browse Customisation Groups
2  Select the [Face] icon of the Font Lock face you wish to change:
   [+]-- [Group] Wp
   [-]-\ [Group] Faces
    |  |--- [Option] Frame Background Mode
    | [+]-- [Group] Facemenu
    | [-]-\ [Group] Font Lock
    |  | [-]-\ [Group] Font Lock Highlighting Faces
    |  |  |  |--- [Face] Font Lock Comment Face
    |  |  |  |--- [Face] Font Lock String Face
    |  |  |  |--- [Face] Font Lock Keyword Face
    |  |  |  |--- [Face] Font Lock Builtin Face
    |  |  |  |--- [Face] Font Lock Function Name Face
    |  |  |  |--- [Face] Font Lock Variable Name Face
    |  |  |  |--- [Face] Font Lock Type Face
    |  |  |  |--- [Face] Font Lock Reference Face
    |  |  |  `--- [Face] Font Lock Warning Face

 


 

 

emacs

Font Colors

Unix

 

Change Emacs Font Colors

Go to

Help::Customize::Browse Customisation Groups

Select the [Face] icon of the Font Lock face you wish to change

 


 

 

Redirect Standard Error

Unix

Windows

 

Redirect Standard Error

Sometimes you want to redirect standard error to standard output in cron, etc. For example, xlock sends its help output to standard error, so without the '2>&1', you can't pipe the help output to a file or to 'more'. It even works in the Windows "Command Prompt".

xlock -help 2>&1 | more

 


 

 

IRIX

 

 IRIX

To set your login screen icon, put, for example, a JPEG in the file:

$HOME/.icon

To create new users acounts use:

/usr/sbin/passmgmt

 


 

 

Macintosh Startup Options

 

Macintosh Startup Options:

During Boot Press:    In order to:
                  
Mouse                 Eject the floppy disk
CMD                   Turn virtual memory off
SHIFT                 Boot with no extensions (not even printing)
OPT                   Prevent windows from opening at startup
c (or CMD-OPT-c)      Boot from a CD-ROM
t                     Mount self on a firewire-connected mac
CMD-OPT               Optionally rebuild the desktop folder
CMD-OPT-SHIFT-DEL     Bypass the boot drive
CMD-OPT-SHIFT-DEL-[X] Boot from SCSI drive with ID [X]
         
CMD-OPT-P-R           Zap the PRAM (do it three times to clear all of it)
CMD-OPT-A-V           Force Mac to recognize the attached monitor as AV model
                      (only works on AV-capagle Macs)
CMD-OPT-CTRL-POWER    Resets the Power Manager on many PowerBook models

When Extensions 
Manager loads Press:  In order to:
                  
Space Bar             Load the extension set of your choice

When the Finder 
starts up, press:     In order to:
                  
CMD-OPT               Rebuild the Desktop File

        
         NOTES:
                  
If you quit the finder (OPT-CMD-ESC) and then quickly hold down CMD-OPT, you 
can rebuild the desktop without restarting...)
         
The finder doesn't start up initially until the 'welcome screen' disappears.

 

 


 

 

nslookup

Unix

 

nslookup

To get a list of machines in a sub-net: (this only works if the DNS provides this service)

nslookup

Outputs something like:

$ Default Server:  gratia.it.hq.nasa.gov
Address:  131.182.119.134

At the prompt, type:

> set type=PTR
> ls -d 119.182.131.in-addr.arpa

(reverse the first three chunks of domain name)

 


 

 

vi

Editor

Unix

 

vi

To reference the file you are 'in' in command mode, type %. For example, to make the current file writeable:

[Esc][:]!chmod u+w %

 


 

 

bash

substitution

Unix

 

command line substitution

Say you enter a command:

prompt> rm /tmp/pirated_my_big_fat_geek_wedding.mov

Let's fix the spelling:

prompt> !!:gs/geek/greek

The above command causes this command to be executed:

prompt> rm /tmp/pirated_my_big_fat_greek_wedding.mov

 


 

 

Geek Code

 

Geek Code

Geek Code explained.

 


 

 

php

Oracle

Unix

 

Install PHP with Oracle Support
         

Note: this tip includes several USENET and WWW sources.

########################################
# Install Oracle client (if necessary)
########################################

Create oracle_settings.sh:

ORACLE_BASE=/usr/local/oracle
export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/8.1.6
export ORACLE_HOME
NLS_LANG=AMERICAN_AMERICA.UTF8
export NLS_LANG
PATH=$PATH:/usr/bin:/usr/ccs/bin:/usr/ucb/bin:
/etc:/usr/openwin/bin:$ORACLE_HOME/bin:/usr/local/bin
export PATH

Edit the tnsnames.ora file in:

$ORACLE_HOME/network/admin/

Install Oracle Client from CD

########################################
# Install PHP
########################################

Now enter the folder where you extracted your Php source code you will need to add the following header files to the main folder and the ext/oci8 folder

nzerror.h 
nzt.h 
oci.h 
oci1.h 
oci8dp.h 
ociap.h 
ociapr.h 
ocidfn.h 
ociextp.h 
oratypes.h 
ori.h 
orl.h 
oro.h 
ort.h 
tnsapi.h 
 

These can be found in the oracle home folder do a search for them they are kind of scattered but you need to get them from a linux box running the full blown oracle server!! you may get lucky and find them within your client version. Once this is done inside your php distribution folder type the folowing

./configure 
#with-apxs=/usr/local/apache/bin/apxs 
#with-oci8=(path to oracle home) 
####################-
# Tom used this:
./configure #with-apxs=/usr/local/apache/bin/apxs #enable-track-vars \
            #with-oci8=/usr/local/oracle/product/8.1.6 \
            #with-oracle=/usr/local/oracle/product/8.1.6 #enable-sigchild
####################-

Then type

make 

Then type

make install 

Then complete the php directions...:

sudo cp php.ini-dist /usr/local/lib/php.ini

This will do everything for you cept two final steps go to you apache bin folder usualy /usr/local/apache/bin and edit the apachectl file and add the following line to the top of it .

export LD_PRELOAD=/usr/lib/libpthread.so 

Now type

./apachectl start 

Bingo your done.

The environment variables set above must be set to start apache

Also I reccomend adding them to any .profile that will need it

(From: http://www.php.net/manual/en/faq.build.php#faq.build.apxs)

1. When I try to build PHP using #with-apxs I get strange error messages.

There are three things to check here. First, for some reason when Apache builds the apxs Perl script, it sometimes ends up getting built without the proper compiler and flags variables. Find your apxs script (try the command 'which apxs', it's sometimes found in /usr/local/apache/bin/apxs or /usr/sbin/apxs. Open it and check for lines similar to these:

my $CFG_CFLAGS_SHLIB  = ' ';          
#substituted via Makefile.tmpl
my $CFG_LD_SHLIB      = ' ';          
#substituted via Makefile.tmpl
my $CFG_LDFLAGS_SHLIB = ' ';          
#substituted via Makefile.tmpl

If this is what you see, you have found your problem. They may contain just spaces or other incorrect values, such as 'q()'.

Change these lines to say:

 my $CFG_CFLAGS_SHLIB  = '-fpic -DSHARED_MODULE'; 
#substituted via Makefile.tmpl
 my $CFG_LD_SHLIB      = 'gcc';             
#substituted via Makefile.tmpl
 my $CFG_LDFLAGS_SHLIB = q(-shared);        
#substituted via Makefile.tmpl

Last, if you reconfigure/reinstall Apache, add a 'make clean' to the process after './configure' and before 'make'.

########################################
# Install Apache
########################################

Prerequisite packages:

       SUNWapchr
       SUNWapchu
       SUNWzlib
       SFWbdb [or SMCdb from sunfreeware.com, and adjust paths appropriately]
         

Check this quickly by running

       pkginfo SUNWapchr SUNWapchu SUNWzlib SFWbdb
         

If there are any missing, install "SUNW" pacakges from the sol8 CDs, and SFW packages from the "companion (freeware) CD"

Configure and Compiling

Once you have downloaded and extracted the php source directory, you should do some prep work by setting the following environment variable:

       export LD_RUN_PATH
       LD_RUN_PATH=/usr/lib:/opt/sfw/lib:/usr/local/lib:
                      /usr/local/ssl/lib:`dbhome`/lib
         

This will ensure that apache wont need some long funky LD_LIBRARY_PATH set to run. Adjust the paths as appropriate for your box. The dbhome stuff is for oracle: remove if you dont have oracle.

You can then configure the source build by running the following command:

./configure 
#with-layout=Apache 
#with-prefix=(where you want to install it at (/usr/local/apache)) 
#enable-module-mime-magic
#enable-shared=headers 
#enable-module=info 
#enable-module=rewrite 
#enable-shared=rewrite 
#enable-module=speling
#enable-shared=speling . 
####################
# Tom used this:
./configure #prefix=/usr/local/apache \
-enable-module=so
####################

Uncomment the php4 lines in

/etc/apache/httpd.conf 

httpd.conf changes

The sun "apxs" binary is slightly broken, so you will have to change

LoadModule php4_module        libexec/libphp4.so

to

LoadModule php4_module        /usr/apache/libexec/libphp4.so

You will also have to uncomment the appropriate AddType lines for php in httpd.conf (Just search for 'php')

Oracle issues

If you get errors like cannot find library, or oci.h, then you may need to do the following as root:

cd  `dbhome'
chmod 0755 lib */public */demo

Additionally, if you want to talk to a remote oracle server (as opposed to one running on your web server), you may have to recompile php to use ODBC, from www.iodbc.org, instead of the normal Oracle client libraries. There is even a PHP-specific HOWTO document on the iodbc website.

If the oracle client libraries work for you, use them. Otherwise, try ODBC.

Misc.

If you forgot the LD_RUN_PATH trick above, and you dont want/cant recompile, you will have to edit /etc/init.d/apache and add the following at the top:

       export LD_LIBRARY_PATH
       LD_LIBRARY_PATH=/usr/local/ssl/lib:/opt/sfw/lib:
                         /usr/local/lib:$ORACLE_HOME/lib

PHP Tutorial

BTW: the official php tutorial is at http://www.php.net/tut.php

Written by: Philip Brown ) 2000,2001

 


 

 

Trinary Operator

Question Mark Colon

C

Javascript

Other Languages

 

Trinary Operator

x = a < b ? a : b;

This is a shortcut for something like:

if (a < b)
   x = a;
else
   x = b;

 


 

 

kill

Unix

 

Kill Processes By Name

To kill a process using a string e.g. "xroach" which appears in the output of ps :

kill -9 `ps -ef | grep xroach | awk '{print $2}'`

 


 

 

Lynx

Text Web Browser

 

Lynx Text Web Browser

To grab an entire web directory such as:

lynx -traversal -crawl -realm $1

This one does more than you probably need

lynx -traversal -crawl -force_html -mime_header -noredir -realm -startfile_ok $1

 


 

 

Materialized Views 

Oracle

 

Oracle & SQL*Plus Stuff

To refresh a materialized view

SELECT mview_name FROM user_mviews;
MVIEW_NAME
###############
MV_provider_to_spec_info
MV_SPECIALTY_TREE
MV_SERVICE_ADDRESS
DESC provider_to_spec_info;
Name                   Null?    Type
###################### ######## ############
PROVIDER_DETAIL_ID     NOT NULL NUMBER(15)
SUBSUBSPECIALTY_ID     NOT NULL VARCHAR2(10)
SOURCE_SPECIALTY_NAME           VARCHAR2(60)
SELECT * FROM provider_to_spec_info WHERE subsubspecialty_id IN ('183', '192');

Refresh a materialized view (this one works)

EXEC DBMS_SNAPSHOT.REFRESH('provider.mv_specialty_tree', 'COMPLETE');

Or

ALTER MATERIALIZED VIEW mv_specialty_tree REFRESH FORCE;   

Or

DBMS_MVIEW.REFRESH('mv_specialty_tree', 'A', '', TRUE, FALSE, 0,0,0, FALSE);
            

To determine what an oracle error means:

OERR ORA 1003

Make Oracle re-analyze and reset DB cost estimates

EXEC DBMS_UTILITY.ANALYZE_SCHEMA(USER, 'ESTIMATE');

Analyze a single table

ANALYZE TABLE mv_location_to_provider_info ESTIMATE STATISTICS;

See the call tree and costs without running procedure

SET AUTOTRACE ON
SET AUTOTRACE TRACEONLY

Create an index named perf13 on a TABLE(column, [column]...) in tablespace prov_ndx

CREATE INDEX perf13 ON location(provider_detail_id) TABLESPACE prov_ndx;

What tables can we see?

SELECT * FROM tab;

Create other commands on the fly:

This:

SELECT 'EXEC provider_batch_remove(' || TO_CHAR(batch_id) ||');' 
FROM provider_load_batch;

Produces this:

EXEC provider_batch_remove(992370331);
EXEC provider_batch_remove(992479988);
EXEC provider_batch_remove(992805114);
EXEC provider_batch_remove(992870972);
EXEC provider_batch_remove(993056698);
EXEC provider_batch_remove(993161816);
EXEC provider_batch_remove(993242392);
EXEC provider_batch_remove(993242784);
EXEC provider_batch_remove(993475974);

You can then simply copy and paste the result into a SQL*Plus.

What procedures are stored?

SELECT DISTINCT type,name FROM USER_SOURCE;
What code is in them?
SELECT DISTINCT type,name,text FROM USER_SOURCE;

What constraints are there?

COLU column_name FORMAT a20;
            
SELECT *
   FROM user_cons_columns
   WHERE ROWNUM < 100
   ORDER BY 3, 4;
            
OWNER    CONSTRAINT_NAME TABLE_NAME COLUMN_NAME          POSITION
######## ############### ########## #########            #########
PROVIDER SYS_C0012905    CATEGORY   ACTIVE
PROVIDER SYS_C0012907    CATEGORY   ACTIVE
PROVIDER SYS_C0012909    CATEGORY   ACTIVE
PROVIDER SYS_C0012908    CATEGORY   ACTIVE
PROVIDER SYS_C0012902    CATEGORY   CATEGORY_DESCRIPTION
PROVIDER SYS_C0012906    CATEGORY   CATEGORY_ID          1
.
.

Make a field nullable:

ALTER TABLE master_claim MODIFY (MASTERCLAIMID NULL);

Alter a constraint:

ALTER TABLE master_claim  DISABLE constraint SYS_C00133859;
SELECT constraint_name, search_condition, STATUS 
   FROM user_constraints 
   WHERE table_name = 'BRIDGE_EOB_DETAIL_REMARKS';
ALTER TABLE MASTER_CLAIM ENABLE CONSTRAINT SYS_C00133594;
ALTER TABLE person_queue DISABLE CONSTRAINT SYS_C00148971;

Explaining SQL

Set up your screen

SET LINESIZE 140
COLU query_plan FORMAT a60

First create a plan_table via the oracle-provided script

@utlxplan.sql

Then fill it with some rows:

EXPLAIN PLAN FOR
SELECT last_name, zip FROM service_address
   WHERE provider_detail_id IN
             (SELECT provider_detail_id
                FROM provider_detail_source_spec
               WHERE active = 'Y'
                 AND source_specialty_id IN
                           ( # NR specialties
                            SELECT source_specialty_id
                               FROM source_specialty_map
                               WHERE provider_type_id = 4 
                               AND active = 'Y'));

Then format the info

SELECT RTRIM (LPAD (' ',2 * LEVEL) ||
              RTRIM (operation) || ' ' ||
              RTRIM (options) || ' ' ||
                     object_name) query_plan,
              cost,
              cardinality num_rows
   FROM plan_table
   CONNECT BY PRIOR ID = parent_id
   START WITH ID = 0;

Using trace/tkprof

ALTER SESSION SET sql_trace TRUE;

Find out where the trace file is dumped (the dir is set by user_dump_dest in init.ora). For example:

/ora01/app/oracle/admin/ST01/udump 

Run script to test in SQL*Plus

Turn it off:

alter session set sql_trace false;

Interpret the trace file

tkprof st01_ora_14137.trc test_get2.txt explain=foo/bar@ST01

Formatting the date

SELECT TO_CHAR (birth_date, 'dd/MON/yyyy hh24:mi:sssss') 
   FROM person 
   WHERE last_name = 'SMITH';

Export tables to a flat file:

exp userid=This email address is being protected from spambots. You need JavaScript enabled to view it. 
     tables=
     CERTIFICATION_INTERFACE,
     HOSPITAL_AFFILIATION_INTERFACE,
     LOCATION_INTERFACE,
     PROVIDER_DETAIL_INTERFACE,
     PROV_DET_SRC_SPEC_INTERFACE,
     PROVIDER_LOAD_BATCH 
     file=c:\data\uds1-provider.dmp 
     consistent=y 
     buffer=10000000 
     feedback=1000
            

SQL*Plus Specific Stuff:

Change the default buffer limit for DBMS_OUTPUT

EXEC DBMS_OUTPUT.ENABLE (90000);
            

Stop a long select, etc.

ALT-F C
            

Run a command line SQL*Plus script

C:\OraHome1\BIN\SQLPLUSW.EXE foo/bar@ST01 @c:\test.sql
            

 


 

 

Keyring

Pass-phrase

PGP

 

PGP

Create a keyring (Remember your pass-phrase!)

/opt/pgp/apps/pgp/pgpk -g 		

Add someone else's public key

/opt/pgp/apps/pgp/pgpk -a ~/tristate_test_key.asc

Verify the key is on key on the keyring

/opt/pgp/apps/pgp/pgpk -l

Sign the key so you don't have to do so each time you use it

/opt/pgp/apps/pgp/pgpk -s		

 


 

 

finger

.plan

Unix

 

.plan

If you put some text in a .plan file, then others can 'finger' you and see your text. Here is a .plan file I have used:

________________________________________________________________________________
Thomas A Rowe
This email address is being protected from spambots. You need JavaScript enabled to view it.
         
GIT d+() s+:+ a C++ ULS++ P+++$ L++ E++@ W+++ N+ o K- w- O M+ 
V PS++ PE Y+ PGP t++ 5+ X++ R tv b++ D++ G e+++ h++ r+++ y+
                               ___           ___     
                   ___        /  /\         /  /\    
                  /  /\      /  /::\       /  /::\   
                 /  /:/     /  /:/\:\     /  /:/\:\  
                /  /:/     /  /:/~/::\   /  /:/~/:/  
               /  /::\    /__/:/ /:/\:\ /__/:/ /:/___
              /__/:/\:\   \  \:\/:/__\/ \  \:\/:::::/
              \__\/  \:\   \  \::/       \  \::/~~~~ 
                   \  \:\   \  \:\        \  \:\     
                    \__\/    \  \:\        \  \:\    
                              \__\/         \__\/   
         
         
01101001 01100110  01111001 01101111 01110101  01100011 01100001 01101110 
01110010 01100101 01100001 01100100  01110100 01101000 01101001 01110011 
01110100 01101000 01100101 01101110  01111001 01101111 01110101 01100001 
01110010 01100101  01110100 01101111 01101111 01100111 01100101 01100101 
01101011 01111001 
________________________________________________________________________________

 

 


 

 

Keyring

Pass-phrase

PGP

 

Python

To separate a file name and path from the combination:

import string
whole_path = "/tm/devl/src/foo.txt"
dirs = string.splitfields(whole_path, '/')

Put the 0th up to the rightmost member of dirs in dirs and put the righmost member of dirs in file

dirs, file = dirs[:-1], dirs[-1]

If dirs has content, but there is nothing before the leading slash, put dirs array member [1] (the 2nd) to the last in dirs

if dirs and not dirs[0]: dirs = dirs[1:]
            
path = string.joinfields(dirs, '/')

To print out all environment variables

import os
environ = os.environ
keys = environ.keys()
keys.sort()
for key in keys:    
    if key == "ENVIRON": print key, " => ", environ[key]

Check and set values of individual env vars

import os
environ = os.environ
if not environ.has_key('FOO'):
     print "No FOO set"
     environ['FOO'] = 'BAR'
if environ['FOO'] == 'BAR':
     print "FOO set"

To do an FTP GET:

import ftplib
grab = FTP("mail.odsnet.com")
test_output = open ("/tmp/local_file_to_write.txt", "w")
grab.cwd("/pub")
grab.retrbinary('RETR euk.tar.gz', test_output.write, 1024)

To do a perl chomp: (string.strip actually removes all leading or trailing space)

import string
foo = "\n 	beyond all recognition 		\n"
print "-" + foo + "-"
bar = string.strip(foo)
print "-" + bar + "-"
tel = string.strip(foo)
print "-" + tel + "-"

To rename a file:

os.rename(name1, name2)

To make a 'boolean' type variable

foo = None	  # None is a special data type which evaluates to false
foo = 0		# evaluates to false
foo = 1		# positive and negative integers eval to true
Convert Strings to INTs
string.atoi()
Convert INTs to Strings
?

To use libraries in python

############################################################################
# CODE STYLE PREFERENCE: I generally prefer to use "import x" over
# "from x import y" since "from x import y" makes a local copy of the
# variables which appears 'magically', whereas when  you "import x" and use
# "x.data_member", "data_member" has its "x" namespace and is clearly x's
############################################################################
import tm_utils
 

 


 

 

Optical Illusion

ASCII Art

 

Optical Illusion
 _        __     _____   __   __
| \    ___) \   |    (  (  )  ) |
|  |  (__    |  |     \  \/  /  |
|  |   __)   |  |      \    /   |
|  |  (      |  |__     )  /    |
|_/    \____/      )___/  (_____|
         

 


 

 

Code Review

 

Code Review Checklist

o Test code
o Change Lotus Issue to "Pending Code Review"
o Send e-mail invitation to group with Issue Attached 
o Make Code Review Packet 
  o Include Issue (don't forget module names and versions)
    o Include code with line numbers 
    o Make sure to comment generously
    o Make sure all comments make sense
  o Include supporting charts/diagrams 
  o Include example output
  o Spell check everything
o MAKE SURE code still works
o Print packet
  o Number all pages of packet
  o Copy, bind and distribute packet
o Make sure reader is prepared to explain code

 


 

 

shells

csh

zsh

Unix

 

Unix shells

To do command-line completion in csh:

[Esc] then [\]

In ksh, '*' does filename completion

In ksh, highlight then touch 'v' to vi that chunk

To configure zsh prior to compilation

./configure 
--bindir=/usr/local/bin 
--infodir=/usr/local/info 
--mandir=/usr/local/man

Differences between the various shells

zsh Startup Shell Configuration:

My startup:
/usr/local/bin/xearth -term 30 -day 100 -night 20 -shade -gamma 1  
     -grid -grid1 15 -grid2 15 -proj orth -mag 1 -rot 0 -pos 'fixed 38.34 
     -098.20' -markerfile /export/home/trowe/.xearth_markerfile_phcs &
/opt/gnome-1.4/bin/xscreensaver &
/usr/local/bin/x2vnc -resurface -west -edgewidth 2 trowe.lumenos.com:0
My .zshrc:
# This file is sourced only for interactive shells. It
# should contain commands to set up aliases, functions,
# options, key bindings, etc.
#
# Global Order: .zshenv, .zprofile, .zshrc, .zlogin
#
# Set up some history stuff... the last 500 commands are saved in ~/.zsh_history
HISTSIZE=500
HISTFILE="$HOME/.zsh_history"
SAVEHIST=500
# Use vi as a command line editor (hit ESC to invoke)
bindkey -v
# Set the prompt to "[bold{user@host}]relative_working_directory$ "
PS1="[%B%m%b]%~$ "
# Use less as the default pager, and -X to stop clearing on exit in 
# an xterm i.e. makes it nice for GNUplot help! The -M gives more 
# verbose info.
PAGER='less -X -M'
export PS1 PAGER EDITOR SAVEHIST HISTFILE HISTSIZE
# No messy core dumps
ulimit -c 0
# File creation permissions
umask 022
# Set default completion to look through all files, then the command history.
compctl -D -f + -H 0 '' -X '(No file found; using history)'
compctl -o setopt
compctl -v echo export
compctl -z -P '%' bg
compctl -j -P '%' fg jobs disown
compctl -j -P '%' + -s '`ps -x | tail +2 | cut -c1-5`' wait
compctl -A shift
compctl -c type whence where which whereis killall man apropos
# kill takes signal names as the first argument after `-', 
# but job names after % or PIDs as a last resort.
compctl -j -P '%' + -s '`ps -x | tail +2 | cut -c1-5`' + \
        -x 's[-] p[1]' -k "($signals[1,-3])" # kill
# magical zsh keys
#  with NO_BEEP set, that annoying beep goes away 
#  with NO_LIST_BEEP, beeping is only turned off for ambiguous completions 
#  with AUTO_LIST set, when the completion is ambiguous you get a list without 
#     having to type \C-D 
#  with BASH_AUTO_LIST set, the list only happens the second time you hit tab 
#     on an ambiguous completion 
#  with LIST_AMBIGUOUS, this is modified so that nothing is listed if there is 
#     an unambiguous prefix or suffix to be inserted 
#     - this can be combined with BASH_AUTO_LIST, so that where both are 
#     applicable you need to hit tab three times for a listing. 
#  with MENU_COMPLETE set, one completion is always inserted completely, 
#     then when you hit TAB it changes to the next, and so on until you get 
#     back to where you started 
#  with AUTO_MENU, you only get the menu behaviour when you hit TAB again on 
#     the ambiguous completion. 
#  Finally, although it affects all completion lists, including those 
#     explicitly requested, note also ALWAYS_LAST_PROMPT, which causes the 
#     cursor to return to the line you were editing after printing the list, 
#     provided that is short enough. 
setopt NO_LIST_BEEP
setopt autolist
setopt list_ambiguous
export ZSHHELPDIR=~/ZSHHELP
function run-help() {
  [[ $1 = . ]] && 1=dot
  [[ $1 = : ]] && 1=colon
	  if [[ $1 = compctl ]]; then
	    man zshcompctl
	  elif [[ -f $ZSHHELPDIR/$1 ]]; then
    less $ZSHHELPDIR/$1
  else
    man $1 || w $1
  fi
}
# <<completion>>  (to ".completion")
# zsh3.0 have these as defaults, but for 3.1.6 I have to set them
# explicitly (and I learned how by comparing the defaults):
# (find-es "zsh" "compctl_defaults")
compctl -b bindkey
compctl -v export
compctl -o setopt
compctl -v unset
compctl -o unsetopt
compctl -v vared
compctl -c which
#function comp_emails () { reply=($(<~/.addrs)) }
#compctl -K comp_emails email email850 emailfile
#sound
function mp () {
  if [[ $
#== 0 ]]; then cd /mp3s/MINE/; \ls -x
  else nice -n -40 /hdc6/usr/bin/freeamp $*
  fi
}
function vol () {
  if [[ $
#== 0 ]]; then aumix -v query
  else aumix -v $*
  fi
}
            
# some helpful options
setopt ALL_EXPORT
setopt CORRECT
setopt MENU_COMPLETE
setopt EXTENDED_GLOB
setopt AUTO_PARAM_SLASH
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_SPACE
# This makes the shell give immediate notice of 
# changes in job status, which is my preference.
setopt NOTIFY
#Aliases
alias vnc_me="x2vnc -resurface -west -edgewidth 2 trowe.lumenos.com:0"
alias lp="lp -o nobanner"
alias xroach="nice -19 xroach -speed 15.0 -roaches 5 -squish -rgc yellowgreen"
alias xsnow="nice -19 xsnow -bg blue -solidbg -snowflakes 100 -notrees -whirl 2 
            -yspeed 3" 
alias xfishtank="nice -19 xfishtank" 
            
#      [-c color]  background color
#	[-b limit]  number of bubbles (default 32)
#	[-f limit]  number of fish (default 10)
#	[-i mult]   move interval (default 0.2)
#	[-r rate]   move frequency (default 0.2)
#	[-m num]    median cut to this many colors
#	[-C num]    use only this many color cells
#	[-d]        clip fish, swim on root window
#	[-p file]   fish swim on picture in file
#	[host:display]
            
#alias killbyname="kill -9 `ps -ef | grep $1 | awk '{print $2}'`
alias xearth_root="xearth -term 30 -day 100 -night 20 -shade -gamma 1  
             -grid -grid1 15 -grid2 15 -proj orth -mag 1 -rot 0 
             -pos 'fixed 38.34 -098.20' 
             -markerfile /export/home/trowe/.xearth_markerfile_phcs &"
alias pobox0="xearth -gamma .3  -nolabel -grid -grid1 30 -grid2 30 -proj merc 
             -mag 8 -rot 0 -pos 'fixed 38.34 -098.20' 
             -markerfile /export/home/trowe/.xearth_markerfile_pobox0 
             -sunpos '38.34 -098.20' -noroot -title 'PO BOX 0' &"
alias pobox_root="xearth -gamma .3  -nolabel -grid -grid1 30 -grid2 30 
             -proj merc -mag 8 -rot 0 -pos 'fixed 38.34 -098.20' 
             -markerfile /export/home/trowe/.xearth_markerfile_pobox 
             -sunpos '38.34 -098.20' &"
alias facility="xearth -gamma .3 -nolabel -grid -grid1 30 -grid2 30 
             -proj merc -mag 8 -rot 0 -pos 'fixed 38.34 -098.20'  
             -markerfile /export/home/trowe/.xearth_markerfile_facility 
             -sunpos '38.34 -098.20' -noroot -title 'PHCS Facility 01/01/2001' &"
alias phcs_world_root="xearth -gamma .3 -grid -grid1 15 -grid2 15 -proj orth 
             -mag 1 -rot 0 -pos 'fixed 38.34 -098.20' 
             -markerfile /export/home/trowe/.xearth_markerfile_phcs 
             -sunpos '38.34 -098.20' &"
alias xsublim="xsublim -font courier -delayShow 100000 -delayWord 100000 
             -delayPhraseMin 5000 -delayPhraseMax 10000 -random -screensaver 
             -outline -center &"
alias xv_burns="xv -geom 1305x1024 -root -smooth -dither -mono 
             -crop 0 0 416 336 /export/home/trowe/images/simpsons/burns.gif" 
alias xv_burns_all_mono="xv -root 
             -mono /export/home/trowe/images/simpsons/bigger_burns.gif" 
alias xv_burns_all="xv -root /export/home/trowe/images/simpsons/bigger_burns.gif"

 

 

Nostalgia

about:

Netscape 3

 

Netscape 3

Netscape 3 abouts

 


 

 

sprintf

 

sprintf

Put the size of the entire transaction + 'Q' into header

The max digits (.*) for the size is set to headerSize-1

(7 - 1) = 6 since there can be 6 digits for size

sprintf (header,"%.*dQ",headerSize-1, xmlString.size()+headerSize);

 

 


 

 

Solaris

SunOS

Unix

 

Solaris

Hardware Model

uname -i

Operating System

uname -a

Memory, processor(s), etc

dmesg | less

Host ID

/usr/sbin/hostid

Create a new user

useradd -g 20 -m -s /usr/bin/csh -u 2002 amato
useradd -g 20 -m -s /usr/bin/csh -u 2004 jhall
useradd -g 20 -m -s /usr/bin/csh -u 2005 gvarros

Font names

    "courier", "courier-bold", "courier-16", "courier-oblique-19",
    "lucidasans", "lucidasans-bold", "lucidasans-9", "lucidasans-italic",
    "palatino-roman", "palatino-bold-14", "palatino-roman-7", "palatino-italic",
    "times-bold", "times-roman", "times-roman-10", "times-italic-14",
    "charter-black", "charter-black-13", "charter-black-italic",
    "helvetica-20", "gillsans", "gillsans-bold", "gillsans-bolditalic",
    "newcenturyschlbk-roman", "newcenturyschlbk-bold-15",
    "rockwell", "rockwell-italic-16", "symbol", "symbol-16",
    "symbol-19", "bookman-demi", "bookman-light-19",
    "avantgarde-book", "avantgarde-demi", "avantgarde-demioblique"

 

SUN OS Version 

Is Solaris Version 

SunOS 5.4

Solaris 2.4

SunOS 5.5

Solaris 2.5

SunOS 5.5.1

Solaris 2.5.1

SunOS 5.6

Solaris 2.6

SunOS 5.7

Solaris 2.7 (or 7)

SunOS 5.8

Solaris 2.8 (or 8)

 

Determine the amount of physical memory (RAM) you have (in KB):

grep mem /var/adm/messages

 


 

 

telnet 80

WWW Client

WWW Server

 

telnet 80

If you want to see what WWW server is running at a given site or if you want to see what headers the server responds with:

telnet www.server.machine 80 [RET]
GET / HTTP/1.0 [RET] [RET]

You have to hit Return twice at the end.

You can do the same thing using HTTP 1.1:

telnet www.server.machine 80 [RET]
GET / HTTP/1.1
Host: online.ibfd.org [RET] [RET]

 


 

 

Folder Name Tab Completion

Command Prompt

Windows 2000

 

Windows Cmd Prompt and Folder Name Tab Completion
                   
         
(From http://www.windows2000faq.com/Articles/Index.cfm?ArticleID=15382)
         
 John Savill / June 12, 2000 
 Q. How do I enable folder name completion?
         
  A. You can set the registry entry
  HKEY_CURRENT_USER\Software\Microsoft\Command
  Processor\CompletionChar to 9 and use the Tab key to enable filename
  completion. However, you can use another setting to enable path completion
  (but not filename completion). To do so, complete the following steps:
         
      1.Start the registry editor (regedit.exe). 
      2.Move to HKEY_CURRENT_USER\Software\Microsoft\Command
        Processor. 
      3.From the Edit menu, select New, then DWORD value. 
      4.Enter the name PathCompletionChar. 
      5.Double-click New Value, and set the value to the desired key (4 sets
        to Ctrl+D). 
      6.Click OK. 
      7.Close the registry editor. 
         
  You don't need to restart Windows; just start a new Command Prompt
  window (cmd.exe).
         
         
(From http://www.windows2000faq.com/Articles/Index.cfm?ArticleID=13571)
         
John Savill / January 9, 2000 
 Q. How can I open a command prompt at my current directory in Explorer?
         
 A. It may be a normal situation you are browsing directories in Explorer and
  want to open a command prompt at the current location without having to
  type a long cd .... to get to the correct directory. It is possible to add a
  context menu option to folders to bring up a "Command prompt here" which
  will open a command prompt at your current explorer location.
         
  A Powertoy, Command Prompt Here, can be downloaded from Microsoft (and
  is also included with the resource kit, cmdhere.inf), however all this does is
  update a couple of registry entries and can be accomplished manually allowing
  greater flexibility
         
      1.Start the Registry Editor (regedit.exe) 
      2.Move to HKEY_CLASSES_ROOT\Folder\shell (you could use
        HKEY_CLASSES_ROOT\Directory\shell but it would then not apply
        to folders, whereas Folder does both) 
      3.From the Edit menu select New - Key and enter a name of CmdHere
        (or anything else) 
      4.Under the new key select New - Key and enter a name of command
        (lowercase) 
      5.Under the key (CmdHere) double click on (Default) and enter a name
        that will be displayed when you right click on the directory, e.g.
        "Command Prompt Here"
        As an extra, if you a & to the front of a character it will cause it to be
        underlined, e.g. "&John Prompt here" would produce John Prompt
        here. 
      6.Move to the command key and again double click on (Default) and
        enter
        \System32\cmd.exe /k cd "%1"
        e.g. c:\winnt\System32\cmd.exe /k cd "%1"
        You can use "%l" instead of "%1" which will support long file names. 
      7.Close the registry editor 
         
  There is no need to reboot the machine and the new option will be available
  when you right click on a folder
         
  In Windows 2000 applying this change also results in a command prompt here
  for drives and not just folders

 


 

 

Quines

 

Quines

":quine: /kwi:n/ /n./ [from the name of the logician Willard van Orman Quine, via Douglas Hofstadter] A program that generates a copy of its own source text as its complete output. Devising the shortest possible quine in some given programming language is a common hackish amusement." - The Jargon File (v4.0.0)

Bourne Shell Script Example:

#! /bin/sh
x="
echo_\"#!_/bin/sh\"
echo_\"x=\\\"\"
for_u_in_\$x;_do_echo_\$u_|_sed_-e_'s/\\([\`\"\$\\]\\)/\\\\\\1/g';_done
echo_\"\\\"\"
echo_\"for_i_in_\\\$x;_do\"
echo_\"eval_\\\`echo_\\\$i_|_sed_-e_'s/\\\\([^\\\\]\\\\)\\_/\\\\1_/g'_|_\\\\\"
echo_\"sed_-e_'s/\\\\\\\\\\_/\\_/g'\\\`\"
echo_\"done\"
"
for i in $x; do
eval `echo $i | sed -e 's/\([^\]\)_/\1 /g' | \
sed -e 's/\\_/_/g'`
done

C Example:

#include <stdio.h>
            
int
main (void)
{
  char *s1="#include <stdio.h>%c%cint%cmain (void)%c{%c";
  char *s2="  char *s%c=%c%s%c;%c  char *s%c=%c%s%c;%c";
  char *s3="  char n='%cn', q='%c', b='%c%c';%c";
  char *sp="  printf(";
  char *s4="%ss1,n,n,n,n,n);%c";
  char *s5="%ss2,'1',q,s1,q,n,'2',q,s2,q,n);%ss2,'3',q,s3,q,n,'p',q,sp,q,n);%c";
  char *s6="%ss2,'4',q,s4,q,n,'5',q,s5,q,n);%ss2,'6',q,s6,q,n,'7',q,s7,q,n);%c";
  char *s7="%ss2,'8',q,s8,q,n,'9',q,s9,q,n);%ss2,'0',q,s0,q,n,'x',q,sx,q,n);%c";
  char *s8="%ss3,b,q,b,b,n);%ss4,sp,n);%ss5,sp,sp,n);%c";
  char *s9="%ss6,sp,sp,n);%ss7,sp,sp,n);%ss8,sp,sp,sp,n);%c";
  char *s0="%ss9,sp,sp,sp,n);%ss0,sp,sp,n,n,n);%c  return 0;%c}%c";
  char *sx="--- This is an intron. ---";
  char n='\n', q='"', b='\\';
  printf(s1,n,n,n,n,n);
  printf(s2,'1',q,s1,q,n,'2',q,s2,q,n);  printf(s2,'3',q,s3,q,n,'p',q,sp,q,n);
  printf(s2,'4',q,s4,q,n,'5',q,s5,q,n);  printf(s2,'6',q,s6,q,n,'7',q,s7,q,n);
  printf(s2,'8',q,s8,q,n,'9',q,s9,q,n);  printf(s2,'0',q,s0,q,n,'x',q,sx,q,n);
  printf(s3,b,q,b,b,n);  printf(s4,sp,n);  printf(s5,sp,sp,n);
  printf(s6,sp,sp,n);  printf(s7,sp,sp,n);  printf(s8,sp,sp,sp,n);
  printf(s9,sp,sp,sp,n);  printf(s0,sp,sp,n,n,n);
  return 0;
}

 


 

 

cvs

Revision Control

Unix/All

 

cvs

To add a directory (e.g. called 'perl_scripts') and all the files in it to a cvs repository:

cd perl_scripts
# cvs import -m "[log message]" [cvs path] [vendor tag] [release tag]
cvs import -m "imported perl scripts" perl_scripts homegrown release_1
# This command will add the files in the cwd to the cvs repository
# in $CVSROOT/perl_scripts
cd ..
cvs checkout perl_scripts

To check out an old revision: (this will check out an entire module tree)

cvs checkout -r 1.15 perl

If you find that a check out gives you sticky problems, check out the file thus:

cvs update -A foo.pl

Then cp the revision you want to become current onto the checked out file:

cp foo_real.pl foo.pl

Then check it back in explicitly:

cvs ci foo.pl

 


 

 

Browser Detection

WWW Browser

Javascript

HTML

 

Client-side Web Browser Detection
         

In general, it is better to detect browser FEATURES and code to them rather than to trust the "User Agent" information browsers send. Some browsers can be configured to disable certain features and/or send the User Agent information of the user's choice.

That being said, sometimes you still want or need to deliver content based in some way on the User Agent info - what a browser claims to be.

The example below throws up a warning HTML doc in a new window warning various browser users that the web site does not yet support them. 

Put this line in the head of the web page to do the browser detection:

<script language="JavaScript" src="/JavaScript/detect.js"></script>

Then serve the following Javascript in the file detect.js:

var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;
            
if (checkIt('konqueror'))
{
        browser = "Konqueror";
        OS = "Linux";
}
else if (checkIt('safari')) browser = "Safari"
else if (checkIt('omniweb')) browser = "OmniWeb"
else if (checkIt('opera')) browser = "Opera"
else if (checkIt('webtv')) browser = "WebTV";
else if (checkIt('icab')) browser = "iCab"
else if (checkIt('gecko')) browser = "Mozilla"
else if (checkIt('msie')) browser = "Internet Explorer"
else if (!checkIt('compatible'))
{
        browser = "Netscape Navigator"
        version = detect.charAt(8);
        if (version == "5") version = "5/6";
}
else browser = "An unknown browser";
if (!version) version = detect.substr(place + thestring.length,detect.indexOf(";",place + thestring.length)-(pl
ace+thestring.length));
if (!OS)
{
        if (checkIt('linux')) OS = "Linux";
        else if (checkIt('x11')) OS = "Unix";
        else if (checkIt('mac')) OS = "Mac"
        else if (checkIt('win')) OS = "Windows"
        else OS = "an unknown operating system";
}
            
function checkIt(string)
{
        place = detect.indexOf(string) + 1;
        thestring = string;
        return place;
}
alert("Tom's Debug: Your browser reports that it is " + OS + " " + browser + " " + version);
// Pre 5.5 IE
if (version < 5.5 && browser == "Internet Explorer")
{
    window.open('browser_ie.html','browser_popup','toolbar=no,width=530,height=530,left=0,top=0,status=no,scrol
lbars=no,resize=no')
}
// Netscape
else if (browser == "Netscape Navigator")
{
    window.open('browser_netscape.html','browser_popup','toolbar=no,width=530,height=530,left=0,top=0,status=no
,scrollbars=no,resize=no')
}
else if (browser == "Mozilla")
{
}
// Other
else if (browser != "Internet Explorer")
{
    window.open('browser_other.html','browser_popup','toolbar=no,width=530,height=530,left=0,top=0,status=no,sc
rollbars=no,resize=no')
}

 

 


 

 

Export and Import

Directory Server

iPlanet

LDAP

 

Copy Directory From One LDAP Server to Another

Export all entries from the source LDAP server:

/usr/iplanet/ldapservers/slapd-svr_1/db2ldif -n userRoot -a /tmp/svr_1.ldif

First, stop slapd on the destination LDAP server:

/usr/iplanet/ldapservers/slapd-svr_2/stop-slapd

Import exported file

/usr/iplanet/ldapservers/slapd-svr_2/ldif2db -n userRoot -i /tmp/svr_1.ldif

Sart slapd again

/usr/iplanet/ldapservers/slapd-svr_2/start-slapd
 

 

Adding Packages

pkgadd

Solaris

 

pkgadd

DO NOT INSTALL packages unless you know what they are and what they do In particular, there are various system packages SUNWcar, SUNWcsr, etc that overwrite basic, core Solaris OS files. Also, if you DO install such OS packages, make sure you know if you should be installing 32 bit or 64 bit packages and for the correct architecture.

64 bit packages in Solaris are identified by an x in the package name. So SUNcarx is 64 bit while SUNcar is 32 bit.

Determine the architecture of your sun machine by consulting manuals or online charts of machines and their architectures.

A Sun Ultra 10 is of the hardware platform "sun4u". The "u" indicates that the SUNcarx.u or SUNcar.u packages are correct for the Ultra 10. Other packages for other hardware platforms have similer names, e.g. SUNcar.m o

To just do an interactive pkgadd session, copy packages into position:

cp -r <various packages> /var/spool/pkg
pkgadd

Or you can specify the package to add. These commands install the Sun Explorer system diagnostic tool package. (Download package from your local support site or http://sunsolve.sun.com)

uncompress SUNWexplo.tar.Z
tar xvf SUNWexplo.tar
pkgadd -d . SUNWexplo

Or you can specify a directory to find packages to add

pkgadd -d /opt/packages_to_install  

To find out if a package has been installed properly: (-v = verbose, show all files in package as they are being examined)

pkgchk -v SUNWperl        

To find out information about a package:

pkginfo SUNWperl  

To find out what packages are installed:

pkginfo

 


 

 

Perl

 

Perl

Pipe data from a process: (caesar decrypts article with rot13)

open ARTICLE, "caesar <$article |";

Pipe data to a process:

open EXTRACT, "|sort > /tmp/tmp$$";

 

 


 

 

ssh

no password

ssh-keygen

PubkeyAuthenticaion

RSAAuthenticaion

authorized_keys

Sun

Unix

 

scp without a password

Without a password, scp from one sun to another sun (via cron, script, etc.).

Connect to scp-source machine (where you will scp FROM)

ssh source.machine.org

Go to the .ssh directory

cd /home/tom/.ssh
ssh-keygen -f id_rsa -t rsa

Use an empty passphrase

[enter]
[enter[

Copy the generated public key to the scp-destination machine

scp id_rsa.pub This email address is being protected from spambots. You need JavaScript enabled to view it.:/home/tom/.ssh

Connect to scp-destination machine (where you will scp TO)

ssh destination.machine.org

Go to the home directory & set permissions

cd /home/tom
chmod go-w .

Go to the .ssh directory

cd .ssh

Add the public key to the authorized_keys file

cat id_rsa.pub >> authorized_keys
chmod 700 .
chmod 600 *

Verify these settings in /usr/local/etc/ssh/sshd_config

RSAAuthentication yes
PubkeyAuthentication yes

Now you should be able to scp from the source machine to the destination machine without a password!

 


 

To Do:

 

   

 

 

 

This email address is being protected from spambots. You need JavaScript enabled to view it.