AIX

Printers

Adding a Printer / queue

Setup for Linux

Ensure you are root or sudo’ed

 

Adding Your First Printer from the Command-Line

Run the lpadmin command with the -p option to add a printer to CUPS:

/usr/sbin/lpadmin -p printer -E -v device -m ppd

or

/usr/sbin/lpadmin -p printer -E -v device -P <directory to ppd file>

For a HP DeskJet printer connected to the parallel port this would look like:

/usr/sbin/lpadmin -p DeskJet -E -v parallel:/dev/lp1 -m deskjet.ppd

Similarly, a HP LaserJet printer using a JetDirect network interface at IP address 11.22.33.44 would be added with the command:

/usr/sbin/lpadmin -p LaserJet -E -v socket://11.22.33.44 -m laserjet.ppd

 

Managing Printer Classes from the Web Interface

The Web interface is located at:

http://localhost:631/admin

 

You may need to check CUPS (Common Unix Printer Services) is installed and running

By default cups installs the following directories:

/etc/cups: Configuration directory.

/var/spool/cups/: The spooler directory where print jobs are held for printing.

/var/spool/cups-pdf: The spooler directory where CUPS-generated PDF files are held for printing.

 

CUPS also installs an executable binary in /etc/init.d/ (or /etc/rc.d/init.d) called cups. This binary is started with the command:

/etc/init.d/cups start/stop/restart

 

Create a printer on linux the hard way.

1. To create a printer called mylp for the /dev/lp1 device, open the /etc/printcap file with your preferred text editor. The sd option tells the Linux printing daemon, lpd, where to temporarily place printed (spooled) files. The mx command, used with a value of 0, places no limit on the size of spooled files. Type an entry such as this:

 

mylp:\
:sd=/var/spool/lpd/mylp:\
:mx#0:\
:lp=/dev/lp1:

2. Save the entry, and then create the printer’s spool directory by using the mkdir command:

mkdir /var/spool/lpd/mylp

3. Make sure the directory lp has the correct group ownership and permissions by using the chgrp and chmod commands, as follows:

chgrp lp /var/spool/lpd/mylp
chmod 755 /var/spool/lpd/mylp

4. Test the printer entry with the lpr (line printer command) using the -P option to specify your newly created printer:

lpr -Pmylp test.txt

5. Your printer should activate and print the test document.

 

Setup for IBM AIX

For this operation you need to be logged in as root or sudo’ed

 

run smit.

-> Print Spooling

-> Aix Print Spooling

-> Add a Print Queue

Select options

*     hpJetDirect

*     Other (Select this if your printer type is not listed above)

*     generic      Generic Printer

*     2 Do NOT make this system a BOOTP/TFTP server

Enter name of queue in ONE of the Names of NEW print queues to add – select PostScript if not sure (e.g. HP4050_QUEUE)

Enter HOSTNAME of JetDirect Card (e.g. HP4050_PRN)

Leave port 9100 as that is nearly always right.

 

Create a printer on Aix the hard way.

 

1. Add the printer to /etc/hosts

10.0.0.111 HP4050

2. Add the print queue

Option a) Generic ASCII

     /usr/lib/lpd/pio/etc/piomkjetd mkpq_jetdirect -p 'generic' -D asc -q 'HP4050asc' -h 'HP4050' –x '9100'

where ‘HP4050asc’ is the queue name and ‘HP4050’ is the host name as specified in /etc/hosts

Option b) Generic Postscript

     /usr/lib/lpd/pio/etc/piomkjetd mkpq_jetdirect -p 'generic' -D ps -q 'HP4050ps' -h 'HP4050' –x '9100'

where ‘HP4050ps’ is the queue name and ‘HP4050’ is the host name as specified in /etc/hosts

 

Buffers in Vim

45732

I have been a long time user of Vim but started to get into some of the more advanced commands and one of my favourite with vim is the use of buffers and splitting the screen. Please note buffers and screen splitting functionality are only available in later versions of vim – version 5 onwards.

Buffers

You can edit multiple files simulatenously.

:e <filename> – To edit a secondary file

:ls – To list all files you are currently editting

:b<1> – To jump to a specific edited file.

:bn – To jump to the next file in the buffer

:bp – To jump to the previous file in the buffer

These last two commands are nice to place into you vim resource file to map a ctrl sequence onto the commands to quickly move between them.

Screen Splitting

Screen splitting is a step beyond and complimentary to buffers. Screen splitting allows to see the window split across the center of the current file (either horizontally or vertically) and allows you to see the currently editted file. This is extremely useful if you want to see your declarations or definition of a piece of code (especially in the same file). This is much prefered to opening a secondary file as you do not get warnings about swap files nor do you need to keep in mind where you can edit as all edits are to the same file.

<ctrl-w>  s – Split screen (horizontally)

<ctrl-w>  v – Split screen (vertically)

<ctrl-w>  c – Close current screen split

<ctrl-w>  k – Move up a screen split

<ctrl-w> j – Move down a screen split

<ctrl-w> l – Move right a screen split

<ctrl-w> h – Move left a screen split

<ctrl-w> r – Reverse screen splits

 

Screen virtual terminal emulation.

Finally as a tip – If you are working with Linux up can use the screen virtual terminal emulator. This will allow you to swap sessions on a virtual terminal

Use the command screen from a terminal session to start the virtual terminal emulator

Once running you can

<ctrl-a> c – To create a new session (no need to log in another session

<ctrl-a> k – To kill the session

<ctrl-a> ” – To list all your running screen sessions

<ctrl-a> A – Will allow you to name (title) each session

<ctrl-a> 1..9 – Will swap you to a given session

<ctrl-a> d – To detach from the session

If you detach, the screen session will continue to run, you can see what is still running with

screen -ls

then re-attach again if you are running just a single one with no session name, or just enough to make unique if more than on is running.

screen -r [session name]

 

Another use of screen permits you to run a session and let multiple users attach and work in it simulateously. This is done by running against a special resource file

screen -c .my_resource

Create .my_resource containing (for example)

sessionname <The session name>
shelltitle <The session name>

multiuser on

 

 

 

 

 

Colourful grep on aix.

1208603

Linux implements a decent version of grep and highlights the search term using colour. Whilst AIX  terminals can support colour (if your term session supports it) with escape codes I have not seen any way of making grep or egrep etc colourful.

On linux you simply add the parameter –color=auto such as
grep --color=auto SearchTerm  {files}

Well as I couldn’t find anything on google I decided to implement something. And this is what I came up with. However the one bug I didn’t manage to resolve was If searching case insensitively the highlighting will only find the correct case. As sed does not support case insensitively this is a problem to solve. If nawk or gawk is installed, they do support it with the -i parameter.


#!/bin/ksh
#************************************************************************
#                                                                       *
# Module Name : grepc.sh                                                *
# Author      : Dave Jarman                                             +
#                                                                       *
# Edit Record (most recent edit at top of list)                         *
# Date          By      CF      Comments                                *
# ---------     ---     ----    --------------------------------------- *
# 5-Apr-12      DCJ i           Use ampersand in sed search results as 
#                               matched string to better handle regular 
#                               expressions (thanks Zolo).
# 20-Sep-11     DCJ             New file                                *
#************************************************************************
#
# Executes grep but with the escape codes to colourise the output.
#
# Known Bugs:
#   If searching case insensitively the highlighting will only find the
# correct case. As sed does not support case insensitively this is a problem
# to solve. If nawk or gawk is installed, they do support it with the -i
# parameter.
#
# Other colours are available. Use the following lines.
# Blue          echo "s/$QRY/\033[1;34m$QRY\033[0m/g" > $TMP/$$.sed
# Light blue    echo "s/$QRY/\033[1;36m$QRY\033[0m/g" > $TMP/$$.sed
# Inverse blue  echo "s/$QRY/\033[44;37m$QRY\033[0m/g" > $TMP/$$.sed
# Red           echo "s/$QRY/\033[0;31m$QRY\033[0m/g" > $TMP/$$.sed
#************************************************************************
# Check for any options and save them
OPT=
while [[ $1 = [-+]?* ]]
do
  OPT="$OPT $1"
  shift
done
#
# Get the search string.
QRY=$1
shift
#
# Create a sed script to subsitiute for the appropriate colour.
# Show the search term in Blue
# echo "s/$QRY/\033[1;34m$QRY\033[0m/g" > $TMP/$$.sed
echo "s/$QRY/\033[1;34m&\033[0m/g" > $TMP/$$.sed
# echo /usr/bin/grep $OPT "$QRY" $* "|" sed -u -f $TMP/$$.sed
/usr/bin/grep $OPT "$QRY" $* | sed -f $TMP/$$.sed
#
# Clean up the tmp file                                                   *
rm $TMP/$$.sed
#
# Finish
exit 0

To check the version of linux you are using

459

To check the version of linux you are using
uname -r

To check the release of the version of linux you are using

llsb_release -a

Clear apache access and error logs safely by

1024

Log in logs
cat /dev/null > /var/adm/wtmp

Access logs
cat /dev/null > /usr/HTTPServer/logs/access_log

Error logs
cat /dev/null > /usr/HTTPServer/logs/error_log

Go to Top