H. MISCELLANEOUS

I put here a few simple scripts that even when they are one or more lines, they might save you some time.


H1. GET CSA AND DEVICE MONITOR HOSTS

The script "get_host" will get the name of your Current "Device Monitor Master Host", and the CSA host, in your system.

You might run this script:

Mainly when you want to confirm the current status of your devices: printers, screens, etc. As you should know, running:

/usr/fox/cs/dm_recon d

on the station acting as Device Monitor Master, it will show the status of your devices in the file:

/usr/fox/cs/cs_dm.current

Note: change directory to: /usr/fox/exten for versions other than 4.2.

As a bonus, the script shows the CSA host in your system. Just as a reminder, or useful if you have been dangerously enabling "temporary" CSA hosts.


H2. CONVERT CASE ON FILENAMES

The script "low2up" will rename lowercase filenames in current directory to UPPERCASE filenames.
The script "up2low" will rename UPPERCASE filenames in current directory to lowercase filenames.


H3. INHIBIT COMPOUND ALARMS

The script "inh_alm" will inhibit alarms from ALL compounds in a selected CP/GW.

This is done by changing the value of the CINHIB parameter to 1.

It is assumed that this script will be used temporarily only to avoid the annoying alarms that come after a CP/GW has been rebooted, by Maintenance purposes.


H4. UN-INHIBIT COMPOUND ALARMS

The script "uinh_alm" will UN-inhibit alarms from ALL compounds in a selected CP/GW.

This is done by changing the value of the CINHIB parameter back to 0, just to return the compounds to their normal state.


H5. GET TOP 15 PROCESSES

The script "g_top15" will give you the list of the top 15 processes that have taken more CPU time up to this moment.

g_top15 output sample:
PID     %CPU    %MEM    TTIME   PROCESS
987     1.0     1.0     41:33   /usr/fox/exten/om_
3       0.7     0.0     37:07   fsflush
1167    0.5     3.5     16:37   /opt/fox/hstorian/
1164    0.1     2.7     9:52    /opt/informix/lib/
1152    0.0     4.0     5:36    /opt/informix/lib/
1       0.0     0.3     4:02    /etc/init
1165    0.1     1.1     3:00    /opt/fox/hstorian/
1148    0.2     2.6     2:24    /opt/fox/hstorian/
1147    0.0     1.8     2:29    /opt/fox/hstorian/
1141    0.1     0.7     2:05    smon_strh
1089    0.0     1.1     1:50    tbinit
989     0.0     0.8     0:03    /usr/fox/exten/om_
988     0.0     0.5     0:02    /usr/fox/exten/om_
981     0.0     0.7     0:00    /usr/fox/exten/om_
980     0.0     0.3     0:00    /usr/fox/exten/mac

If you prefer you might use "g_top15a" that gives you more characters on the process name column. The same code lines are used inside the script "chk_awp" as part of the AP report.

g_top15a output sample:
TTIME   PID     PROCESS
41:33   987     /usr/fox/exten/om_server
37:08   3       fsflush
16:37   1167    /opt/fox/hstorian/bin/sampling_ctl histcc
9:52    1164    /opt/informix/lib/sqlturbo root 5.00.UD1 AAA#C397039
5:36    1152    /opt/informix/lib/sqlturbo root 5.00.UD1 AAA#C397039
4:02    1       /etc/init -
3:00    1165    /opt/fox/hstorian/bin/reduction_ctl histcc
2:29    1147    /opt/fox/hstorian/bin/hist_srv
2:24    1148    /opt/fox/hstorian/bin/hs_fetch
2:05    1141    smon_strh CCSM01 SM0N03
1:50    1089    tbinit
0:57    1168    /opt/fox/hstorian/bin/archiving_ctl histcc
0:27    1029    /usr/fox/exten/nfd_8023
0:18    1166    /opt/informix/lib/sqlturbo root 5.00.UD1 AAA#C397039
0:10    1163    /opt/fox/hstorian/bin/collect_msg_1 histcc
0:09    1170    /opt/fox/hstorian/bin/ipchisti histcc
0:09    1032    /usr/fox/sysmgm/sysmon/smon_ech
0:07    1088    tbinit
0:06    1169    /opt/informix/lib/sqlturbo root 5.00.UD1 AAA#C397039
0:05    1014    /usr/fox/exten/smat

H6. LIST PROCESSES BY ID#

ld is not an script. It is simply an alias defined in /.cshrc.

For 50 stations add this line:

alias pss 'ps -aux | sort +1 -2'

For 51 stations use the line:

alias pss 'ps -ef | sort +1 -2'

Whenever I want to know which are the newest processes, typing pss will give me a list of all processes, with the newest ones at the end.

NOTE: Remember that to activate the new aliases, you have to exit and enter again to the C-shell. Type csh and you will have the aliases available.

I use this 'command' to know for example which process to kill whenever the terminal looks hanged. Of course, I have to run pss from another terminal or session.


H7. LIST FILES BY DATE

Another alias line that I always use is:

alias lt 'ls -lrt'

This will give me the list of all files in current directory, in a long format, sorted by time in reverse order.


H8. dtree

I did not write this script. A friend of mine gave it to me. I think it was taken from Unix Power Tools book (that I do not have). I recommend it because it can give you a directory tree of the current directory, or the directory you specify in the argument.

I like this smart script even when I still do not understand completely the use of "@" instead of "/" in the sed command. (Any hints?)


H9. LIST ONLY DIRECTORIES

A similar line that you might want to include in your /.cshrc file is:

alias ld 'ls -l | grep ^d'
Typing ld will allow you to get a list of only the subdirectories under the current one. Useful when you are in a crowded directory and you want to hide the regular files from the list.


H10. LIST FILES BY SIZE

You have two choices here. First, you can place in /.cshrc this line:

alias lss 'ls -l | grep "^-" | sort -n +4 -5 | more'
And then, typing lss will produce a list of files in long format, sorted by size, with the big files at the end.

Another way is to create the following "lss" script:

ls -l | grep "^-" | sort -n +4 -5 > z
awk '
{
sum += $5
++filenum
}
END {
printf("\t%d files\t%d bytes\n", filenum, sum)
}' z
more z
rm z

The advantage is that the script will give you also the total number of files in that directory, and the total number of bytes. To use it, go to the desired directory and type /opt/ac/lss, or just lss if you have modified your path to include directory /opt/ac.

lss output sample:
        130 files       4367030 bytes
-rw-r--r--   1 root     other          0 Jul 16 11:12 CCDI02.fbm
-rw-r--r--   1 root     other          5 Jul  4  1996 test1.out
-rw-r--r--   1 root     other         17 Aug 22 13:30 ps.dat
-rw-r--r--   1 root     other         59 Jun  6 10:37 cp04
-rw-r--r--   1 root     other         67 Jun  6 10:37 cp03
-rw-r--r--   1 root     other         68 May 28  1997 last2.inp
-rw-r--r--   1 root     other         70 Jul 16 10:40 cc_cps
-rw-r--r--   1 root     other         72 May 24  1996 ac.sql
-rwxr-xr-x   1 root     other         80 Oct 10 09:43 get_ov.ac
-rw-r--r--   1 root     other         82 May 24  1996 ac1.sql
-rwxr-xr-x   1 root     other        103 Jul 28 08:40 bigs_filter
-rw-r--r--   1 root     other        106 Mar 15  1996 CMXHLNODE.BIN
-rwxr-xr-x   1 root     other        106 Oct  3 14:22 run
-rwxr-xr-x   1 root     other        108 Jun  5 17:05 acx1_go
-rwxr-xr-x   1 root     other        108 May 24  1996 acprep
-rwxr-xr-x   1 root     other        109 May 24  1996 ac_prep
.....
.....

H11. LIST FILES BY SIZE (REVERSE ORDER)

Everything said on the previous paragraph applies here, except that the sorting is done in reverse order, and the big files will be at the beginning of the list.

lsr output sample:
        131 files       4367030 bytes
-rw-r--r--   1 root     other     501532 Aug 27 17:08 ccap01.dsk
-rw-r--r--   1 root     other     374530 Aug 18 16:37 CD23FCC
-rw-r--r--   1 root     other     283244 Oct  3 15:28 OPERATIONS
-rw-r--r--   1 root     other     283142 Oct  3 15:32 OPERATORa.Fri
-rw-r--r--   1 root     other     283142 Oct  3 15:31 OPERATIONS.Fri
-rw-r--r--   1 root     other     283142 Oct  3 15:31 OPERATIONS.
-rw-r--r--   1 root     other     278598 Jul 16 10:11 CCCP01.icc
-rw-r--r--   1 root     other     238773 Jul 16 10:13 CCCP02.icc
-rw-r--r--   1 root     other     211557 Jul 16 10:20 CCDI01.icc
-rw-r--r--   1 root     other     189516 Jul 16 10:18 CCCP05.icc
-rw-r--r--   1 root     other     172862 Jul 16 10:16 CCCP04.icc
-rw-r--r--   1 root     other     153840 Oct 30 08:36 x
-rw-r--r--   1 root     other     139315 Jun  5 17:01 x1
-rw-r--r--   1 root     other     127488 Jul 16 10:23 CCDI03.icc
-rw-r--r--   1 root     other     111542 Jul 16 10:14 CCCP03.icc
-rw-rw-rw-   1 root     other      90483 Aug 19 11:22 cc_fbm
....
....

The line for /.cshrc would be:

alias lsr 'ls -l | grep "^-" | sort -r -n +4 -5 | more'

The script named "lsr" would be in this case:

ls -l | grep "^-" | sort -r -n +4 -5 > z
awk '
{
sum += $5
++filenum
}
END {
printf("\t%d files\t%d bytes\n", filenum, sum)
}' z
more z
rm z

I prefer this script most. I am always cleaning hard disks to recover space and I prefer to start looking for the big files first.


H12. SQUEEZE

Finally, I don't know if you would ever use this script: "squeeze". What it does is to hide the blank, comment (#), and echo ".." lines from the script entered as argument.

I use it to look at the real lines that do the job in long scripts. The comments are good however to remind you of what you were doing on the script you wrote a long time ago, and also to help a person who would improve your script. Never trust your memory!.



Index - Home


This page hosted by
Get your own Free Home Page