TACL Expansions and Side Effects

Expansions return information to you and a side effect does something.   An example of an expansion is a builtin.  It returns information to you.

Expansion basically means using the contents of a variable or a builtin.  This is refered to as a function procedure.   When using and expansion you place brackets around it [variable].   In order for this to work during interactive sessions you must have the following builtins set:
#SET #INFORMAT TACL
#SET #OUTFORMAT PRETTY

Here is an example of ausing variable x to return information:
PUSH x
#SET x Denver
#OUTPUT The capital of Colorado is [x].
The capital of Colorado is Denver

You can also use nested expansions.  It will expand the inside first:
#OUTPUT [#CONTIME [#TIMESTAMP] ]
    this looks like:
      #OUTPUT [#CONTIME 48574739495]
    then:
     #OUTPUT 1998 06 12 11 22 34 95

TACL Check Disk Use

In Linux you can check disk usage by typing df -h.

You can do the same thing with TACL on a Tandem by typing dsap $V,short

Using grep to Find Multiple Things

When I first started using unix I used grep quite often.  I came across a problem though.  I needed to be able to grep for multiple terms.  I came up with egrep.

You can use egrep to grep for multiple things.  Here is an example:
egrep  “(term1|term2)” file

You can also use grep to read from list and search a file
grep -f list file

Depending on what you’re trying to do either may work or one may work better than the other. 

 

TACL if then else

The format for IF statements is:

[#IF <condition>
|THEN|
<action>
|ELSE|
<action>
]

Example:
[#IF (count > 10 )
|THEN|
#OUTPUT Count is over 10
|ELSE|
#OUTPUT Count is not over 10
]

Cluster SSH cssh

I found a cool tool called cluser ssh.  It opens up multiple SSH sessions so that when you type it comes out on all the machines you’re connected to.  It makes it easy to update clusters of boxes at one time. 

To Install:
On Ubuntu from a command line type: 
 sudo apt-get install clusterssh

/etc/clusters lets you setup aliases for all the machines you want to access.  An example of /etc/clusters:
NAME user@host1 user@host2 User@host3

When you start cssh you can specify the name:
cssh NAME

This can save you a lot of time if you need to make the same update across several nodes. 

 

Comparisons in KSH (equal to and not equal to)

You’d think computers would be smart enough to figure out a simple comparison, but they aren’t.  You have to be specific when comparing strings or numerical data…At least in korn shell.

To compare strings use “=” for equal and “!=” for not equal.
To compare numbers use “-eq” for equal “-ne” for not equal.

EX:
if [[ $lastname = "Johnson" ]];then
   # list your commands here….
fi
if [[ $years -eq 10 ]];then
   # list your commands here….
fi

FTP is not Secure

When transfering files on the internet, it’s best to not use FTP.  Here’s why. 

When you initiate an FTP session everything you send is sent ‘in the clear’.  Meaning that anyone who can analyze the network traffic can see your user id and password.  Other transfer options like SFTP/SCP are encrypted and/or use a key exchange.  This scrambles the data and makes it near impossible to view the information being sent. 

Just some tech tip I figured I’d pass along!

How to Remove Tabs in vi editor

If you want to get rid of tabs in vi you can use a global search and replace. 
%s/^V^M//g

When you type the control-V it will actually disappear.  Your command will look like this:
%s/^M//g

How to Mount a Windows Drive on Ubuntu

I had an old windows formatted hard drive (NTFS) and wanted to mount it to the Linux file system.  Here’s how I did it from the command line:

First create a directory you will mount it to:
sudo mkdir -p /media/w

Then get a list of available partitions:
sudo fdisk -l

You’ll want to mount the NTFS partition like this:
sudo mount -t ntfs -o nls=utf8,umask=0222 /dev/hdb1 /media/w

SQLCI BEGIN, ROLLBACK AND COMMIT WORK

When using SQLCI it is a good idea to use these commands when editing tables.

SQLCI
BEGIN WORK;
<use your sql statement to insert or delete records>
COMMIT WORK;
If you wanted to, before you commit you can undo your changes:
ROLLBACK WORK;