Wednesday, December 26, 2007

Password proetct pages in Apache

create a password encoded .httaccess file with

http://www.4webhelp.net/us/password.php
http://shop.alterlinks.com/htpasswd/htpasswd.php
http://www.htmlite.com/HTA006a.php

in form of user:encoded_password

then add the following to corerct section in httpd.conf file

AuthUserFile /full/path/to/.htaccess
AuthType Basic
AuthName "Authorization Required"
Require valid-user

restart apache

Monday, December 24, 2007

Cacti on Windows

The following have to be set in the cacti->settings

PATH
spine path is to be set
rrdtool font is to be set like c:/cacti/arial.ttf

GENERAL
RRDTOOL version must match the installed rrdtool

Saturday, December 15, 2007

NIS AUTOMOUNT

1. server: /etc/exports, define exportable directories

/users *(rw,no_root_squash,no_all_squash,sync)
/apps *(ro,sync)

2. server: service nfs restart

3. server: /var/yp/Makefile, edit to include auto.* in make all
(YP server is to be installed first)

4. server: /etc/auto.master :: <--- REMEMBER NO /etc in front of auto.*
/users auto.home --ghost
/apps auto.local --ghost

5. server: /etc/auto.home ::
* -rw dcssrv4:/users/&

6. server: /etc/auto.local ::
oracle -ro dcssrv4:/apps/oracle
gf_admin -ro dcssrv4:/apps/gf_admin

7. server: cd /var/yp;make

8. server: service ypserv restart

9. client: edit /etc/nsswitch.conf :: automount nis files

10. client /etc/sysconfig/network :: put NISDOMAIN=xxxxxxx

11. client /etc/yp.conf :: put domain NISDOMAIN server XXXX

12. client: service ypbind restart & service autofs restart

look at http://penguin.triumf.ca/recipes/nis-auto/index.html
(it has an error, check the instrucion #4 above)

Wednesday, December 12, 2007

geoframe document errors

1. gf_admin must be of group dba
2. chmod 775 /home/oracle

Tuesday, December 11, 2007

qemu resize image file

1. qemu-img convert system.qcow -O raw system.raw
2. dd if=/dev/zero of=system.raw seek=N obs=1GB count=0 (N=final size)
3. qemu-img convert system.raw -O qcow growed-system.qcow

Monday, December 10, 2007

QEMU change cdrom

1. start qemu with -monitor stdio option along with other options
2. press CTRL+ALT+2 to enter CLI mode and CTRL+ALT+1 to exit
3. enter command "change cdrom isofilename.iso"

Sunday, December 09, 2007

remember you stupid that

files that start with . (dot) in linux will be hidden from plain ls, Gnome deskop,...

Wednesday, December 05, 2007

Oracle SNMP for Cacti monitoring

from http://forums.cacti.net/about6209.html
Step 0 : Enverionment

OS : SunOS dbateam 5.8
Oracle Version: 8.1.6

Step 1 : Stop Sun's snmpdx process.

login as root account:
1-0
%ps -ef | grep snmp | grep -v grep
root 6438 1 0 Sep 10 ? 0:01 /usr/lib/dmi/snmpXdmid -s bscss02d
root 6427 1 0 Sep 10 ? 0:20 /usr/lib/snmp/snmpdx -y -c /etc/snmp/conf
%
%kill -9 6438 6427

1-2
# ps -ef | grep mib
root 6405 1 0 Nov 01 ? 0:24 mibiisa -r -p 32934
root 2373 1 0 Oct 21 ? 3:23 mibiisa -r -p 32882
root 6512 1 0 Nov 01 ? 0:25 mibiisa -r -p 32956
root 6578 1 0 Nov 01 ? 0:26 mibiisa -r -p 32977
root 6620 1 0 Nov 01 ? 0:01 mibiisa -r -p 32998
root 6558 1 0 Nov 01 ? 0:24 mibiisa -r -p 32972
root 6434 1 0 Nov 01 ? 0:30 mibiisa -r -p 32941
root 7284 7280 0 19:03:46 ? 0:00 mibiisa -r -p 40714
# kill -9 6405 2373 6512 6578 6620 6434 7284

1-3
check process of oracle snmp
%ps -ef | grep peer
root 6607 1 0 Nov 01 ? 0:06 ./encap_peer -t 1162 -s 1160 -c CONFIG.encap
root 6605 1 0 Nov 01 ? 0:13 ./master_peer CONFIG.master NOV
%kill -9 6607 6605


Step 2 : Start Oracle Snmp

2-0: check $ORACLE_HOME/network/snmp/peer/CONFIG.master
COMMUNITY public
ALLOW ALL OPERATIONS
USE NO ENCRYPTION
MANAGER xxx.xxx.xxx.xxx
SEND ALL TRAPS

2-1: check $ORACLE_HOME/network/snmp/peer/CONFIG.encap
AGENT AT PORT 1161 WITH COMMUNITY public
SUBTREES 1.3.6.1.2.1.1,
1.3.6.1.2.1.2,
1.3.6.1.2.1.3,
1.3.6.1.2.1.4,
1.3.6.1.2.1.5,
1.3.6.1.2.1.6,
1.3.6.1.2.1.7,
1.3.6.1.2.1.8,
1.3.6.1.4.1.11.2
FORWARD ALL TRAPS;

2-3: check start_peer
SNMPD=/usr/lib/snmp/snmpdx
SNMPD_CONFIG=/etc/snmp/conf
SNMPD_OPTIONS=-y


2-4: loging as root

%/bin/ksh
%export ORACLE_HOME=/oracle/816/product/8.1.6
%cd $ORACLE_HOME/network/snmp/peer/
%./start_peer -a
Starting master_peer ...
./master_peer CONFIG.master NOV >master_peer.out 2>&1 &
Done!

Starting encap_peer ...
./encap_peer -t 1162 -s 1160 -c CONFIG.encap >encap_peer.out 2>&1 &
Done!

Starting /usr/lib/snmp/snmpdx ...
/usr/lib/snmp/snmpdx -y -c /etc/snmp/conf -p 1161 >snmpd.out 2>&1 &
Done!

check files ( master_peer.out,encap_peer.out,snmpd.out )
there will be no content,if start oracle snmp success,like ..
%ls -ltr *.out
-rw-r--r-- 1 root other 0 nov 2 19:11 master_peer.out
-rw-r--r-- 1 root other 0 nov 2 19:11 encap_peer.out
-rw-r--r-- 1 root other 0 nov 2 19:11 snmpd.out

startup oracle listener for dbsnmp
su - oracle account
agentctl start
%snmpwalk -Os -v 1 -c public 172.16.28.223 1.3.6.1.4.1.111

Tuesday, December 04, 2007

Windows: computer cannot connect to some sites

Windows: Computer cannot connect to some websites to which other have absolutely no problems connecting:

ipconfig /flushdns

can help A LOT!!!

Thanks to my brother Moslem Saleh

Monday, December 03, 2007

Tuesday, November 27, 2007

Oracle minimal client installation

1. Oracle basic client/or basic lite in case you need only English language. (oracle litebasic for windows is only 8 megs, how beautiful is that!)

2. These environment variables are to be set:

$ENV{'ORACLE_HOME'} = "d:/oracle";
$ENV{'TNS_ADMIN'} = "d:/oracle";
$ENV{'LD_LIBRARY_PATH'} = "d:/oracle";

3. Put tnsnames.ora in the path specified by $ENV{'TNS_ADMIN'}

Sunday, November 25, 2007

DBD::Oracle Activestate Perl on Windows

1. Oracle 9 oci.dll has problems with the function calls within oralce.dll by Activestate

2. Do not use the Graphical Perl Package Manager use ppm install/uninstall command prompt tool instead

3. Download the Oracle instant client avaiable from Activestate. (agree to the oracle disclaimer at the end of the ppm install DBD-oracle)

4. If after complete installation of DBD-Oracle still you got messages like procedure entry point not found, replace the oralce client oci.dll with the ones provided by activestate.

You are good to go

Monday, November 19, 2007

Oracle Sort Paging

Oracle does not have the keyword limit like mysql, you have to select couple of rows and limit them by rownumbers, this may cause problems when sorting because you may only sort the set that you have selected, so first select and sort all then limit by rownums

select * from
    (select p.*, rownum r from
        (select * from all_objects order by object_name) p
    where rownum < 20)
where r > 10;

THANKS ASKTOM

Friday, November 16, 2007

bash echo problem with filenames with whitespaces

taken from http://textsnippets.com/posts/show/1105 --thanks so much guys

Bash Internal field seperator has to be changed to $'\n' like this

export IFS=$'\n'

now when u do
for i in `ls`;echo $i;done

spaces will not be treated as field seperators and consequently the whole filename is displayed completely.

Sunday, November 11, 2007

ORACLE 9 installation document error

ALTHOUGH oracle 9 installation document tells you that ORACLE_BASE does not have to be set prior to installation of oracle, THIS IS TOTAL BULLSHIT!!!!! YOU HAVE TO SET ORACLE_BASE.

Monday, November 05, 2007

solaris install window decoration/theme

solaris install window decoration/theme with http://www.blastwave.org CSW qt and kde packages. (all installed in default locations)

./configure --with-qt-dir=/opt/csw/kde-gcc --with-qt-includes=/opt/csw/include

** in case KDE libs were not being found although they were installed remove QT libs from $LD_LIBRATY_PATH just keep KDE libs,

*** REMOVE anything you added to LD_LIBRARY_PATH in case your applications started behaving erratically.

Tuesday, October 30, 2007

Solaris manual default gateway change

route add -net 0.0.0.0/0 163.183.37.1

Solaris Ethernet connectivity related files

/etc/hosts
/etc/nodenames
/etc/hostname.[device]
/etc/defaultrouter
/etc/defaultdomain
/etc/nodename

Monday, October 29, 2007

Perl regular expressions

(a*b*)* in perl == ((a*b*)*)

matches can be accessed in internal var$ $1,..$n
complete match is in $&

[a-zA-Z0-9] = \w

(\w*) = macthes anything alphanumeric + "_"

$line =~ m/((\w*-*)*)/; will match combinations of above plus "-"
$result = $1;
or
$result = $line =~ m/((\w*-*)*)/;

Tuesday, October 23, 2007

Read man pages directly

nroff -man smbmount.8 | more

Putty login with no password

1. ssh-keygen -t rsa -C ali@ali.com -f ~/.ssh/id_rsa
2. mail -s "my private ssh key" ali@ali.com < ~/.ssh/id_rsa
3. cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys2
4. chmod 600 ~/.ssh/authorized_keys2
5. download http://the.earth.li/~sgtatham/putty/0.60/x86/puttygen.exe
6. Convert the save key from email and save as private key file.
7. in Putty->SSH->Auth select the file.

To disable password based login after creating the public/private key pair

change the following in /etc/ssh/sshd_confing
PermitRootLogin no
PasswordAuthentication no
UsePAM no

*** REMEMBER NOT TO LOSE THE private key
HAVE PHUN

Monday, October 22, 2007

Oracle drop user error

ORA-00600: internal error code, arguments: [qmxiUnpPacked2], [121], [], [], [],
solution:
connect as sysdba
1)SQL> shutdown immediate

2)SQL> startup migrate

3)SQL> spool patch.log

4)SQL> @?/rdbms/admin/catpatch

5)SQL> spool off

Oracle create database and user

Oracle create user in 3 steps;
1. RUN DBCA successfully.
2. SQL> create user username identified by password default tablespace users temporary tablespace temp;
3. SQL> grant connect, resource to username;

Sunday, October 21, 2007

mysql startup on solaris

cd /usr/local/mysql1/bin
./mysql_install_db --user=mysql --ldata=/sqldata
./mysqld_safe --datadir=/sqldata --user=mysql &

Saturday, October 20, 2007

Solaris Samba Mount using shlight

shlight //srv0r/Segnts/Gest/SUPPORT //root/win -U alisadeghi -P alipassword -W domain

Saturday, September 22, 2007

Solaris Default Route

edit /etc/defaultrouter
route add default $ROUTER_IP_ADDRESS

Tuesday, September 11, 2007

make Perl modules on Solaris with GCC

To prevent the usual problems due to the lack of CC on solaris, you should download and install GCC from sunfreeware.com then change the following parameters in the Makefile and do make & make install

1. Change CC=cc to CC=gcc or ln -s gcc to cc
2. Change
CCCDLFLAGS = -KPIC
to
CCCDLFLAGS =
3. Change
OPTIMIZE = -xO3 -xspace -xildoff -xarch=v8
to
OPTIMIZE =
4. Change
CCFLAGS = -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -xarch=v8 -D_TS_ERRNO
to
CCFLAGS = -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_TS_ERRNO

source: http://atmail.com/view_article.php?num=251
We thank the superman above who initially wrote this!

Monday, September 03, 2007

HTML within Perl code

print<<"tab1";
#HTML CODE GOES HERE
tab1

Thursday, August 09, 2007

Install Cisco VPN Client on Linux

#!/bin/bash

# Fedora Core Cisco VPN Client install notes by Jason Roysdon - http://jason.roysdon.net/
# Creative Commons Attribution-ShareAlike 2.5 - http://creativecommons.org/licenses/by-sa/2.5/
# http://jason.roysdon.net/credits.html

# This patch allows the Cisco VPN Client 4.8.00 (0490) to install with the 2.6.19 kernel.
# It should work for other distros, but here are my FC5/FC6-specific notes.
#

# original source of fix:
# http://www.tuxx-home.at/cmt.php?article=/2006/12/07/T09_36_48/index.html
# patch:
# http://www.tuxx-home.at/projects/cisco-vpnclient/vpnclient-linux-2.6.19.diff

# Run as this as root

# fc3 had the kernel source info with the kernel rpm before, but as of kernel-2.6.12-1.1372_FC3 the following is required:
yum -y install kernel-devel
# with fc5, I now have to install the following for my P4 which looks like an SMP:
yum -y install kernel-smp-devel.i686

mkdir -p /opt/download
cd /opt/download

echo You must login to CCO manually and attempt to download the client for their ftp server to recognize your request:
echo http://cisco.com/cgi-bin/tablebuild.pl/vpnclient-3des
wget -c --user=YOUR-CCO-USER --password=YOUR-CCO-PW http://ftp-sj.cisco.com/cisco/crypto/3DES/vpn/client/linux/vpnclient-linux-x86_64-4.8.00.0490-k9.tar.gz
wget -c --user=YOUR-CCO-USER --password=YOUR-CCO-PW http://ftp-sj.cisco.com/cisco/crypto/3DES/vpn/client/linux/vpnclient-linux-4.8.00.0490-readme.txt

tar xfvz vpnclient-linux-x86_64-4.8.00.0490-k9.tar.gz
cd vpnclient

# get 2.6.19 patch
wget -c ftp://jason.roysdon.net/pub/jroysdon/linux/vpnclient-linux-2.6.19.diff
patch -i vpnclient-linux-2.6.19.diff

# create /usr/local/bin, as on FC6 it doesn't exist by default
mkdir -p /usr/local/bin

# run the install, take the defaults
./vpn_install

# I want my non-root user to be able to start the vpn
chmod 4111 /opt/cisco-vpnclient/bin/cvpnd

# start the service the first time
/etc/init.d/vpnclient_init start

# I like to quickly be able to see what connections I have with a custom 'vpnlist' command:
echo echo > /usr/local/bin/vpnlist
echo echo /etc/opt/cisco-vpnclient/Profiles/ >> /usr/local/bin/vpnlist
echo ls -b /etc/opt/cisco-vpnclient/Profiles/ >> /usr/local/bin/vpnlist
echo echo >> /usr/local/bin/vpnlist
chmod 4111 /usr/local/bin/vpnlist

# I use runlevel 4 for when I'm trying to preserve battery or want a fast bootup and want minimal services running
chkconfig --level 4 vpnclient_init off

Saturday, July 21, 2007

HLRCHECK Script

1. Linux of Other BSD system
2. Apache 2
3. Perl (Net::Telnet, DBD, DBI::Oracle)
4. Oracle Client
5. JRE 1.5
6. Mcreate Query Library (Leonard has the source)
7. Good RAM
8. As an enhancement this app should be forked into three children and each should do each of the tasks.


Scripts

1. hlrcheck:/var/www/html/index.html
2. hlrcheck:/var/www/cgi-bin/telnet2.cgi
3. hlrcheck:/var/www/cgi-bin/telnet1.cgi

FTP by Telnet (PASSIVE MODE)

ftp by telnet (passive mode) works behind NATTED client too

1. telnet 65.111.171.126 21
2. USER anonymous
3. PASSWORD a@a.net
4. CWD mp3/voa/english/spec/2006
5. PASV (will print 65,111,171,126,p1,p2
6. telnet 65.111.171.126 p1*256+p2
7. on the first telnet session type LIST and the results will be displayed in 2nd telnet session


BTW: kheili mokhlessim!