Monday, August 24, 2009

OpenSSL & OpenSSH Installation (From Source)

Installing ssl and ssh will be somehow straightforward task after installing the AIX Linux Toolbox. Both openssl and openssh source tar balls support AIX 6, means that, it correctly guesses the machine type and operating system without modification any config file. Giving an installation directory (i.e. prefix) when installing a program from the source is a good practice. Otherwise 'make install' command scatters the files to various directories (/usr/bin, /usr/lib, etc.) and removing the s/w can be very tedious task in such a case.

OpenSSL

./config --prefix=/www/ssl -shared
make
make install

giving the -shared parameter will be a good idea in order to have shared object library files.

OpenSSH

./config --prefix=/www/ssh --with-ssl-dir
make
make install

Thursday, August 6, 2009

Apache-PHP Compilation in AIX 6.1

coming soon..

cc1 "out of memory allocating" bytes "after a total of" parse_date.lo

You can TRY turning off all optimizations when building. (remove all -O flags from CFLAGS) That tends to require less memory. (ref http://forums.vpslink.com/gentoo/324-problems-mysql-php-vsplink2.html)

http://bugs.php.net/bug.php?id=35863&edit=1

[6 Jan 2006 10:06am UTC] derick@php.net
Objection
You shouldn't try to outsmart our configure by specifying your own
CFLAGS. Apparently GCC does some very heavy optimizations with -Os that
use a lot of memory for our complex parser for date and time strings,
and you don't have enough memory for this.

Wednesday, July 15, 2009

The parameter list is too long...

It is somewhat common to get an error message like the one in the title. When there are lots of file in a directory, either removing or doing any kind of operation with them is a little bit annoying. There is an article called "Avoid common errors in UNIX and Linux" published on July 14th at IBM developerWorks AIX and UNIX section. I want to include the related part , which summarizes the issue well and gives a solution for it, here:*

./foo: /usr/bin/ls: 0403-027 The parameter list is too long.

A program has been running for months on your IBM® AIX® computer without issue. But while the program is running, it creates a file every few minutes in the same directory for logging. The file names begin with f. and e.. The directory is becoming full, and the ls command is slowing down drastically on response time. That is understandable, because the directory has so many files in it.

A few more months go by, and the AIX program continues to run consistently and without problem. There are now 100,000 files that begin with f. and another 100,000 files that begin with e. Now, when you attempt to clean up the log directory of only the files that begin with f., you receive the following message:

# rm ~cormany/logs/f.*
ksh: /usr/bin/rm: 0403-027 The parameter list is too long.

I guess you waited too long before cleaning up the files. No time like the present, however.

When executing a command like delete, all arguments are validated and expanded before execution. The example provided is looking for ~cormany/logs/f.*, which expands to become 100,000 arguments to the command rm. In other words, instead of rm ~cormany/logs/f.*, what is actually being executed is rm ~cormany/logs/f.1 ~cormany/logs/f.2 ~cormany/logs/f.3 … ~cormany/logs/f.100000.

AIX, like other UNIX and Linux operating systems, has a set size for the number of command-line arguments and environment variables that can be used. To view the set size in AIX, use the command getconf. Per the man page for getconf, you should look at ARG_MAX:

# man getconf

ARG_MAX
Maximum length, in bytes, of the arguments for one of the exec
subroutines, including environment data.

# getconf ARG_MAX
1048576


This value tells you that you have 1,048,576 bytes you can use for environment variables and command-line arguments to execute. It looks like you exceeded that. To resolve this issue, two options are available:

  • Increase the amount via smitty chgsys and change ARG/ENV list size in 4K byte blocks or via chdev. I do not recommend changing a system-wide parameter every time you run into this type of error out of convenience: This should be the last resort.
  • Rather than using the command rm with 100,000 arguments, which will fail miserably, the command find does a much better job of removing the files:
    # find ~cormany/logs –name “f.*” –exec rm {} \;

    The find command searches the directory for any files beginning with f. rather than placing the burden on the shell's command line. The find command then executes rm on each file found, thus removing every file beginning with f.


By the way, xargs can be another alternative (may be the first) for resolving this issue, as well. Today, I experience a problem with a script which gives the error; \script[5]: no space. Using xargs also resolves this issue (actually the main problem is the too many file names in the find command, find .... | xargs ls can also solve the problem but, changing the first line to #!/bin/bsh also solves the problem)

* The whole article can be accessed from http://www.ibm.com/developerworks/aix/library/au-unixerrors/index.html

Wednesday, July 8, 2009

Trip Html comments with sed without changing file attributes

The following script* changes a file but preserves its modification time (using touch). Perl is the key point here which provides the file attributes in the desired format for touch input

#!/bin/bash
# ALL HTML FILES
FILES="*.htm*"
# for loop read each file
for f in $FILES
do
INF="$f"
OUTF="$f.out.tmp"
ts=`/usr/bin/perl preserve.pl $f`
sed -f tag.sed $INF > $OUTF
/usr/bin/cp $OUTF $INF
/usr/bin/rm -f $OUTF
/usr/bin/touch -c -t $ts $INF
done
Preserve.pl ***

#!/usr/bin/perl -w
$filename = "$ARGV[0]";
@attrs = stat($filename);

use Time::Format qw(%time %strftime %manip);

print $strftime{'%Y%m%d%H%M.%S',$attrs[8]}

* This script is mostly adapted from http://www.cyberciti.biz/faq/sed-howto-remove-lines-paragraphs/

** Slightly modified the script from http://sed.sourceforge.net/grabbag/scripts/strip_html_comments.sed

*** Uses the Format.pm file which resides on http://search.cpan.org/~roode/Time-Format-1.11/lib/Time/Format.pm

Tuesday, July 7, 2009

Various Things (To be categorized later)

mkuser -a `lsuser -a -a id pgrp groups home shell gecos "ALL"`

This command will collect necessary information and imports all user information to the new system.

Install fixes on a directory

instfix -T -d /dir | instfix -d /dir -f-

Which process uses this port?

lsof | grep `netstat -Aan | grep LISTEN | grep PORT_NUMBER | awk {'print $1'}`

very useful source for sed scripts

http://sed.sourceforge.net/grabbag/scripts/

Port forwarding

ssh -l root -L 5902:localhost:5901 192.168.12.44

Sorting
lsuser -a id ALL | sort -k 2.2b > user_list.txt

this command basically sorts the users according to the their ids, if it comes sorted according to some another key by default.

.sqrt problem solution
http://www.safearea.com.au/web/guest/aix