piątek, 26 lipca 2013

start if stop WLST script

print 'reading domain ...'
readDomain('/u01/middleware/user_projects/domains/marek')
nmConnect('weblogic', 'password', 'localhost', '5556', 'marek', '/u01/middleware/user_projects/domains/marek','ssl')


status = nmServerStatus('AdminServer')
if status == True:
        print 'ok'
elif status == 'SHUTDOWN':
        print 'server is in SHUTDOWN state, starting ...'
        nmStart("AdminServer")
else:
        print 'dupa'

how to decode weblogic password

1. Make a file with name decryptpasswd.py under your_domain/security folder  with below  
    contents
2.
from weblogic.security.internal import *
from weblogic.security.internal.encryption import *

#This will prompt you to make sure you have SerializedSystemIni.dat file under #current directory from where you are running command
raw_input("Please make sure you have SerializedSystemIni.dat inside the current directory, if yes press ENTER to continue.")

# Encryption service
encryptionService = SerializedSystemIni.getEncryptionService(".")
clearOrEncryptService = ClearOrEncryptedService(encryptionService)

# Take encrypt password from user
pwd = raw_input("Please enter encrypted password (Eg. {3DES}Bxt5E3...): ")

# Delete unnecessary escape characters
preppwd = pwd.replace("\\", "")

# Decrypt password
print "Your password is: " + clearOrEncryptService.decrypt(preppwd)

3. Get your encrypt password
4. Now go to  your_domain/bin directory
5. Run setDomainEnv.(sh/cmd)
6. Change directory to your_domain/security ( where you placed decryptpasswd.py script )
7. Run below command

$ java weblogic.WLST decryptpasswd.py

poniedziałek, 22 lipca 2013

/lib/ld-linux.so.2: bad ELF interpreter: No such file or directory

In basic system like CentOS there can be one problem when we want to install for example weblogic version wls1211_linux32.bin:

yum install glibc.i686 or yum install glibc.i386

oracle xe allow remote login

SQL> EXEC DBMS_XDB.SETLISTENERLOCALACCESS(FALSE);  
  
PL/SQL procedure successfully completed.

oracle xe in centos

Few step to start oracle xe database in centos distro:

1. set oracle ENV - shell script default in: /u01/app/oracle/product/11.2.0/xe/bin/

  • . oracle_env.sh

2. check env

  • echo $ORACALE_HOME

3. enter to sqlplus

  • cd $ORACLE_HOME/bin && ./sqlplus /nolog

prompt:
4. Enter to DB

  • SQL:> connect sys@xe as sysdba

enter password:

du

du -hsx * | sort -rh | head -10 -> show size of all directory in present localization.
du --max-depth=1 /home/ | sort -n -r - show size of all directory from path

środa, 3 lipca 2013

python subprocess module example

>>>import subprocess
>>>subprocess.call('ls | wc -l', shell=True)
3
0 --> finish successfully
>>>subprocess.call(['touch', 'plik'])
0
>>>subprocess.call(['ls', '-ltr'])
razem 8
-rw-r--r-- 1 root root  28 lip  2 14:28 plik.tajemny
-rwxr-xr-x 1 root root 680 lip  3 10:24 test.py
-rw-r--r-- 1 root root   0 lip  3 10:34 plik
0

error example:
>>>subprocess.call('ls | wc -lasd', shell=True)
wc: błędna opcja -- 'a' -->; error message
Napisz 'wc --help' dla uzyskania informacji.
ls: błąd zapisu: Przerwany potok
1 -->; error code

the same error code OS use when we try to execute wrong command
simple example from the OS

root@ubu:~# cat /etc/passwd123
cat: /etc/passwd123: there is no file
root@ubu:~# echo $?
1

very cool script

What is Subprocess?
The subprocess module in Python allows you to spawn processes, connect to their
input/output/error pipes, and obtain their return codes.

This module intends to replace several other, older modules and functions,
like: os.system, os.spawn*, os.popen*, popen2.* commands.

Subprocess is probably the most important Python module for system administrators.

#!/usr/bin/env python
import subprocess
import os

def find():
    y = raw_input("Enter a text you want to search on the system!")
    s = y.rstrip("\n")
    print "string", s
    find = subprocess.Popen([r"/usr/bin/find", "/", "-name", y, "-print"], stdout=subprocess.PIPE)
    for line in find.stdout.readlines():
        print "line", line
        l = line.rstrip("\n")
        list = subprocess.Popen([r"ls", "-l", l], stdout=subprocess.PIPE)
        list_stdout = list.communicate()[0]
        print list_stdout
    file = subprocess.Popen([r"file", l], stdout=subprocess.PIPE)
    file_stdout = file.communicate()[0]
    print file_stdout

def main():
    find()

python - shell command execute

1. install python-pip - alternative Python package installer
2. pip install sh - install sh module
3. from python shell:


>>> import sh

print sh.ifconfig("wlan0")

>>> from sh import ifconfig

print ifconfig("wlan0")

# print the contents of this directory

>>> print ls ("-ltr")

razem 4 -rw-r--r-- 1 root root 28 lip 2 14:28 plik.tajemny 

vim file encryption

Vim is very powerful tool and give you even simple encryption service

1. marek@ubu:~$ vim -x testfile
enter passphrase key twice

2. marek@ubu:~$ cat testfile
VimCrypt~01!wUmarek@ubu:~$ file testfile

3. file testfile: Vim encrypted file data


wtorek, 2 lipca 2013

Run build in PHP server

1. Install package:
-- yum install php5-cli
-- apt-get install php5-cli
2. execute command
-- php -S 127.0.0.1:8080 for the comfortable ussage i recommend to use:

  • nohup php -S 127.0.0.1:8080 & -- all the output now we have in nohup.out file and the PHP server process are in the background.