<

Welcome to ScriptLab Site

Big & Exciting news :

As our team and bussiness become bigger and bigger,

we will move soon to a new home.

Only for you guys take a glance on the new proud of the team.

It will look better , it will be more user friendly and it will be more secure.

and of course it will include all our Tips and all our scripts and more!.

Click Here to get out new Home Page :

The new home page

For any feedback,question,request please mail me to: scriptlab@cambioapps.com

Special announcement:

Gift script is aviable under INFO/Holiday gift script

Tip of the Day: 28 January 2020

Maven life cycle

1. Unit Testing

2. Integration Testing

3. System Testing

4. Acceptance Testing

Unit Testing: A Unit is a smallest testable portion of system or application which can be compiled, liked, loaded, and executed. This kind of testing helps to test each module separately. The aim is to test each part of the software by separating it. It checks that component are fulfilling functionalities or not. This kind of testing is performed by developers.

Integration Test: Integration means combining. For Example, In this testing phase, different software modules are combined and tested as a group to make sure that integrated system is ready for system testing. Integrating testing checks the data flow from one module to other modules. This kind of testing is performed by testers.

System Testing: System testing is performed on a complete, integrated system. It allows checking system's compliance as per the requirements. It tests the overall interaction of components. It involves load, performance, reliability and security testing. System testing most often the final test to verify that the system meets the specification. It evaluates both functional and non-functional need for the testing.

Acceptance testing: Acceptance testing is a test conducted to find if the requirements of a specification or contract are met as per its delivery. Acceptance testing is basically done by the user or customer. However, other stockholders can be involved in this process.

Tip of the Day: 02 September 2019

Missing Shared for Elastic Search

In ES many times status chnage to be Yelleo / Red in case of missing Shared

Command to check:

curl -XGET 'http://host_name:9200/_cluster/health?pretty=true'

{ 
"cluster_name" : "TEST", 
"status" : "red", 
"timed_out" : false, 
"number_of_nodes" : 1, 
"number_of_data_nodes" : 1, 
"active_primary_shards" : 24, 
"active_shards" : 24, 
"relocating_shards" : 0, 
"initializing_shards" : 0, 
"unassigned_shards" : 48, 
"delayed_unassigned_shards" : 0, 
"number_of_pending_tasks" : 0, 
"number_of_in_flight_fetch" : 0, 
"task_max_waiting_in_queue_millis" : 0, 
"active_shards_percent_as_number" : 33.33333333333333 
} 

We can see there are 48 unassigned_shards and in this case and since I have 1 node for Elastic Search i need to find out why ?

Found out that contents do not exist in the disk. Explaining it with index_test: the data folder structure in 2.3 is: nodes -> 0 -> indices -> index_test -> shard number So, that index has 12 shards; in that index_test folder we should have 12 sub folders named 0, 1, etc. The diagnostic is showing that shards 1, 2, 4 and 6 are not allocated, and those folders do not actually exist in the disk, according to the tree output. The same occurs for index swm_staging_tracks_2019_3, in which the non allocated shards 0, 3, 5 and 7 do not exist in the disk, and swm_staging_vehicles, in which the shards 1, 3, 5 and 7 do not exist in the disk.

Resolved by : create the missing Shared by firing this command:

curl -XPOST 'host_name:9200/_cluster/reroute' -d '{"commands": [{"allocate": {"index": "index_test","shard": 1,"node": "TEST","allow_primary": "true"}}]}'

curl -XGET 'http://:9200/_cluster/health?pretty=true'
{
"cluster_name" : "TEST",
"status" : "green",
"timed_out" : false,
"number_of_nodes" : 1,
"number_of_data_nodes" : 1,
"active_primary_shards" : 36,
"active_shards" : 36,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 0,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 0,
"active_shards_percent_as_number" : 100.0
}

Tip of the Day: 11 September 2017

Delete files from specific month: in below exmaple from March

for file in `ls -l /home/path | grep Mar | awk '{print $9}'`; do rm -f $file; echo deleted file : $file; done

Tip of the Day: 05 April 2017

Check Linux version

uname ľa

Result: Linux (HostName) 4.4.23-31.54.amzn1.x86_64 #1 SMP Tue Oct 18 22:02:09 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Tip of the Day: 29 March 2017

I am getting lots of emails regarding the support after buying a script.

Each script has all information about it and I am trying to make it very clear what are the capabilities of it and how to use it.

So.. Please ask all questions before buying the script in order to avoid misunderstanding.

I am also support and help post buying but it will be limit due to time limits I am having

Cheers !! And have a good programing day !!

Tip of the Day: 21 March 2017

New service command for RH 7.2 and above

sudo systemctl start (name of the service).service

sudo systemctl stop (name of the service).service

sudo systemctl status (name of the service).service

Tip of the Day: 14 March 2017

Check the Table Space Capacity for Oracle:

select df.tablespace_name "Tablespace", totalusedspace "Used MB",

(df.totalspace - tu.totalusedspace) "Free MB", df.totalspace

"Total MB", round(100 * ( (df.totalspace - tu.totalusedspace)/ df.totalspace))

"Pct. Free" from (select tablespace_name, round(sum(bytes) / 1048576)

TotalSpace from dba_data_files group by tablespace_name) df,

(select round(sum(bytes)/(1024*1024)) totalusedspace, tablespace_name

from dba_segments group by tablespace_name) tu where

df.tablespace_name = tu.tablespace_name and df.totalspace <>0 order by 5 asc

Tip of the Day: 7 March 2017

Are you working with both Oracle and replication to Elasticsearch ?

Are you sure both DBs are in sync ?

If not buy this script and be sure moment a way.

  • Sync Script
  • Tip of the Day: 21 February 2017

    Check what is Listen to 8080 and dump all results to a file:

    tcpdump port 8080 and '(tcp-syn|tcp-ack)!=0' -w test.pcap

    Tip of the Day: 15 January 2017

    find the MAC by execute:

    ifconfig -a | grep HWaddr

    Tip of the Day: 14 January 2017

    Verify the elasticsearch ports are open 9200,9300 :

    netstat -na | grep -E '9200|9300'

    Tip of the Day: 13 January 2017

    Get Elasticsearch info :

    curl -XGET 'http://(server name/IP):port'

    Tip of the Day: 12 January 2017

    How to check Linux version second way:

    lsb_release -a

    Results:

    LSB Version:base-4.0-amd64:base-4.0-noarch:
    core-4.0-amd64:
    core-4.0-noarch:
    graphics-4.0-amd64:graphics-4.0-noarch:
    printing-4.0-amd64:printing-4.0-noarch
    Distributor ID:RedHatEnterpriseServer
    Description:Red Hat Enterprise Linux Server 
    release 6.4 (Santiago)
    Release:6.4
    Codename:Santiago

    Tip of the Day: 11 January 2017

    How to check Linux version:

    cat /etc/*-release

    Tip of the Day: 10 January 2017

    Get apache MQ console page:

    http://(Server IP):8080/amq

    Tip of the Day: 9 January 2017

    Find number of process/threads per user:

    ps uH p | wc -l

    Tip of the Day: 8 January 2017

    Check network setting such as MAC address:

    ifconfig

    Tip of the Day: 7 January 2017

    Check if localhost listens to specific port:

    netstat -tulpn | grep 433

    Tip of the Day: 6 January 2017

    Check Memory info on Linux:

    cat /proc/meminfo

    Tip of the Day: 5 January 2017

    Check what is my public ip:

    curl ifconfig.me

    Tip of the Day: 4 January 2017

    Check the DB size before backup or any other reason:

    select round((sum(bytes)/1024/1024/1024),2) "Data files size (GB)" from v$datafile; select round ("Reserved_Space(GB)",2) as "Reserved_Space(GB)", round ("Reserved_Space(GB)" - "Free_Space(GB)",2) as "Used_Space(GB)", round ("Free_Space(GB)",2) "Free_Space(GB)" from( select (select sum(bytes/(1014*1024*1024)) from dba_data_files) "Reserved_Space(GB)", (select sum(bytes/(1024*1024*1024)) from dba_free_space) "Free_Space(GB)" from dual );

    Tip of the Day: 3 January 2017

    Check CPU statistics 4 times with 3 seconds interval:

    sar 3 4

    %iowait: it's the time spend by processor waiting for devices (input and output)

    %idle: it's the idle time spend by the processor.

    Tip of the Day: 2 January 2017

    If RMAN backup failed with below errros:

    ORA-27037: unable to obtain file status

    Linux-x86_64 Error: 2: No such file or directory

    Do the following:

    As Oracle user :

    rman target /

    RMAN> crosscheck archivelog all;

    Try to backup once more.

    Tip of the Day: 1 January 2017

    RMAN Backup script for ORACLE DB:

    RMAN Backup script

    Tip of the Day: 31 December 2016

    How to check what is running in the background :

    crontab -l

    Tip of the Day: 30 December 2016

    PL/SQL, TNS versions using with Oracle:

    SELECT * FROM v$version;

    Tip of the Day: 29 December 2016

    to check who is connecing to the TUXIDO server:

    ps -ef |grep $USER |grep jsl

    Tip of the Day: 28 December 2016

    boot the tuxedo server:

    tmboot

    Tip of the Day: 27 December 2016

    combine lsof and grep to show all ports on which your system is LISTENING:

    lsof -i | grep LISTEN

    Tip of the Day: 26 December 2016

    Get input from user:

    Please type "YES" to continue or "NO" to cancel the operation"

    read answer

    if [ $answer = "YES" ] || [ $answer = "yes" ] || [ $answer = "y" ] || [ $answer = "Y" ]

    then

    Tip of the Day: 25 December 2016

    Wish you all Good Christmas and Happy new year!

    Tip of the Day: 24 December 2016

    Find Home path and set it in: HOME_PATH

    HOME_PATH=$(cat Test.properties | awk -F= '$1 == "home_path" {print $2}')

    Tip of the Day: 23 December 2016

    Get PID and set it :

    pid=`ps aux | grep "[O]test.jar" | awk '{print $2}'`

    Tip of the Day: 22 December 2016

    Every Java process should be limited(RAM consuming wise)

    Otherwise it will consume all the RAM in the system and can cause Out Of Memory problem

    In order to do it you should limit the process in the kick off as the below example

    java -Xmx2048m -Xms2048m -XX:MaxMetaspaceSize=512m -jar test.jar

    Tip of the Day: 21 December 2016

    Get Action from user and use it:

    $act= STDIN should be inside <>;

    if($act eq 1) {}

    if($act eq 2) {}

    Tip of the Day: 20 December 2016

    Get Date with Perl:

    ($sec,$min,$hour,$mday,$mon,$year

    ,$wday,$yday,$isdst) =localtime(time);

    our $Date = sprintf("%.2d-%.2d-%.2d",$mon+1,$mday,$year+1900);

    our $Time = sprintf("%.2d_%.2d_%.2d",$hour,$min,$sec);

    Tip of the Day: 19 December 2016

    Can not find the mac address on Linux with: ifconfig ?:

    You can find it with:

    cat /sys/class/net/eth0/address

    Tip of the Day: 18 December 2016

    Check if there is firewall in Linux:

    service iptables status

    If Firewall is on you can :

    service iptables stop

    Tip of the Day: 17 December 2016

    As root user, you can see the messages Linux wrote in:

    less /var/log/messages

    Tip of the Day: 16 December 2016

    Find the top memory consuming processes on Linux:

    ps aux --sort -rss | head

    Tip of the Day: 15 December 2016

    After changing DNS in the windows network adapter

    many times the impact is not right a way

    in order to resolve it, Windows flash dns:

    from command line run: ipconfig /flushdns

    Test with ping that you are getting the new DNS.

    Tip of the Day: 14 December 2016

    run sqlplus from Linux:

    sqlplus "user/pass@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=hostname.network)(Port=1521))(CONNECT_DATA=(SID=remote_SID)))"

    Tip of the Day: 13 December 2016

    The /etc/hosts file

    As your machine gets started, it will need to know the mapping of some hostnames to IP addresses before DNS can be referenced.

    This mapping is kept in the /etc/hosts file

    As root user do vi /etc/hosts and add the new mapping you need.

    Tip of the Day: 12 December 2016

    Unable to Connect to SSL Services due to PKIX Path Building Failed:

    Attempting to access applications that are encrypted with SSL (for example HTTPS, LDAPS, IMAPS)

    throws an exception and the connection is refused.

    1.Make sure you have imported the public certificate

    of the target instance into the truststore according to the Connecting to SSL Services instructions.

    2.Make sure any certificates have been imported into the correct truststore; you may have multiple JRE/JDKs.

    3.Check to see that the correct truststore is in use.

    If -Djavax.net.ssl.trustStore has been configured, it will override the location of the default truststore, which will need to be checked.

    4.Check if your Anti-Virus tool has "SSL Scanning" blocking SSL/TLS.

    If it does, disable this feature or set exceptions for the target addresses (check the product documentation to see if this is possible).

    5.If connecting to a mail server, such as Exchange, ensure authentication allows plain text.

    6.Verify that the target server is configured to serve SSL correctly. This can be done with the SSL Server Test tool.

    7.If all options above does not resolve the problem, you can download the SSLPoke tool and test with it.

    You Can Download the SSLPoke in the menu bar link.

    Tip of the Day: 11 December 2016

    In this script it's running 100 times, every time copy Test.xml to Test1,Test2...Test100

    Searching for Text 1.zip and replacing with 1,2,3....100.index

    When index=101 it exit

    for (( index=1; index<=100; index++))

    do

    cp /home/Import/Test_Orig.xml /home/Import/Test$index.xml

    sed -i "s#1.zip#$index.zip#g" /home/Import/Test$index.xml

    done

    Tip of the Day: 10 December 2016

    Declare 'FOR' command in Sh script:

    for ((index=1;index<=2;index++))

    do

    Command1,Command2,Command3

    done

    Tip of the Day: 09 December 2016

    Set the length of a given file in Sh script:

    file_len=`cat 1.txt | wc -l`

    Tip of the Day: 08 December 2016

    How to run FOR command for dos:

    FOR /l %f in (1,1,100) DO Test.py -i FileName$f.xml>log.txt

    In that exmaple i am running from 1 to 100, every time Test.py script with input: FileName$f.xml and output goes to log.txt

    Tip of the Day: 07 December 2016

    How to send mail via Linux ?

    mailx is a Unix utility program for sending and receiving mail and we will use it with below command:

    cat test.txt |mailx -s "Subject of the mail" test@gmail.com test1@gmail.com

    In This exmaple i am sending the content of file "test.txt" to test@gmail.com test1@gmail.com

    Tip of the Day: 06 December 2016

    check the current Java version:

    java -version

    check the current Ant version:

    ant -version

    check the current sqlplus version:

    sqlplus -V

    check the current Python version:

    Python --version

    To verify gcc is insatlled:

    gcc -v

    Tip of the Day: 05 December 2016

    After yesterday tip about the keytool, I got many mails saying that peoples are not willing to work in Linux and keytool and ask me if there is any better way, so.. there is always a better way see in the link.

    How to add new crt file to existing jks file:

    Add new certificate

    Tip of the Day: 04 December 2016

    SSL Certificate

    When using secure connection between the clients and the server an SSL certificate is needed.

    The certificate file used by many applications is a Java Key Store (JKS) which is a repository of security certificates. In order to create a JKS file use the

    following commands on the certificates provided by the authorized CA:

    keytool -import -trustcacerts -alias root

    file gd_bundle.crt -keystore ${keystore.file}

    keytool -import -trustcacerts -alias intermed

    file gd_intermediate.crt -keystore ${keystore.file}

    keytool -import -trustcacerts -alias ${server.name}

    file ${server.name}.crt -keystore ${keystore.file}

    Tip of the Day: 03 December 2016

    Top cpu Proc command:

    ps -auxf | sort -nr -k 3 | head -10

    Tip of the Day: 02 December 2016

    On Linux, as the root user, create a dedicated user you need and a dedicated user group for this user.

    I makes the following assumptions:

    1)The dedicated user is test

    2)The user’s home directory is /home/test

    3) The user belongs to the group test.

    Example:as root user run this command:

    useradd -d /home/test test

    Create password for 'test' user with this command:

    passwd test [enter test password]

    Tip of the Day: 01 December 2016

    ***Free sh Script***

    Change Account

    In this script the user need to provide 3 inputs, path old_account new_account

    for example if you need to change ip in all files you can run as ./Change_Account.sh . 192.168.1.1 192.168.100.2

    in the above , the script will check in all files and whenever he will find

    old_account=192.168.1.1 it will replace it to new_account=192.168.100.2

    #!/usr/bin/ksh

    if [ $# -ne 3 ]

    then

    echo "Usage: change_account path old_account new_account"

    exit 1

    fi

    export _path=$1

    export _old=$2

    export _new=$3

    find $_path -type f -exec grep -l $_old {} \; > /tmp/list$$

    for i in `cat /tmp/list$$`

    do

    echo "Working on $i"

    mv $i /tmp/$$

    cat /tmp/$$ | sed -e "s#$_old#$_new#g" > $i

    done

    exit

    Tip of the Day: 30 November 2016

    On Linux, as the root user, create a new user let’s call it ‘test’

    useradd -d /home/test test

    passwd test [enter test password]

    Tip of the Day: 29 November 2016

    Sh script tip:

    how to check if you are running the script as 'root' user, and second check is to see if file exist :

    if [ $EUID -eq 0 ]; then

    echo "[Info] Detected user is running this tool as root"

    exit 0

    fi

    if [ ! -e "test.properties" ]; then

    echo "Cannot find test.properties"

    fi

    Tip of the Day: 28 November 2016

    Create backup table , in order to work on it :

    create table Tablename_99 as select * from Tablename where application_id='bob';

    in that example , you have Tablename as the origin table let’s call it Tablename=prod and we are creating backup table as Tablename_99=prod_99 once we are creating condition that will never be correct as application_id='bob' we are insuring the new table will be empty.

    if we want to copy all entries from the origin table we can use condition as a=a , as this one will always be correct it will copy all entries from origin table to the new backup table.

    Tip of the Day: 27 November 2016

    Short and nice script to move all files in specific directory from a name "*.*.done" to "*.*.xml" :

    for i in *.xml.processing.done

    do

    base=`basename $i .xml.processing.done`

    mv $i $base.xml

    done

    Tip of the Day: 26 November 2016

    Find the mac address on Linux if command ‘ifconfig’ is not enough :

    cat /sys/class/net/eth0/address

    Tip of the Day: 25 November 2016

    You are checking free -m and all the RAM is busy, from other hand nothing run on the system ?

    To free pagecache, dentries and inodes:

    command is : sync; echo 3 > /proc/sys/vm/drop_caches

    Tip of the Day: 24 November 2016

    Basic select from a table to count the number of the entries in it

    SELECT COUNT(*) FROM table_name;

    Tip of the Day: 23 November 2016

    Are you going to Upgrade the DB Schema, or New Install do you need to take a backup for it ?

    If Yes that is the way , connect to the Oracle Linux server , connect as sysdba to the DB and run :

    expdp 'Admin User Name'/'Admin Password' DIRECTORY='Which directory to save the dmp file' DUMPFILE='**.dmp' LOGFILE='Log file name' SCHEMAS='Schema name';

    Tip of the Day: 22 November 2016

    Change owner for a directory and all the files in it:

    chown -R root:root (folder_name)

    in this case i am changing the directory to be root(can be done if you are connecting with user 'root',

    and all the files under it

    Tip of the Day: 21 November 2016

    Very usefull VBS to connect to Console Admin without typeing user/password all the time :

    Save the file as *.vbs

    WScript.Quit Main

    Function Main

    Set IE =

    WScript.CreateObject

    ("InternetExplorer.Application","IE_")

    IE.Visible = True

    IE.Navigate "http://Host IP:PORT/console/login/LoginForm.jsp"

    Wait IE

    With IE.Document

    .getElementByID("j_username").value = "USER NAME "

    .getElementByID("j_password").value = "PASSWORD"

    .getElementByID("loginData").submit

    End With

    End Function

    Sub Wait(IE)

    Do

    WScript.Sleep 500

    Loop While IE.ReadyState < 4 And IE.Busy

    Do

    WScript.Sleep 500

    Loop While IE.ReadyState < 4 And IE.Busy

    End Sub

    Sub IE_OnQuit

    On Error Resume Next

    WScript.StdErr.WriteLine "IE closed before script finished."

    WScript.Quit

    End Sub

    Tip of the Day: 20 November 2016

    Check the Elasticsearch is up and running :

    curl -XGET 'http://elastic_hostname:9200'

    Check cluster health:

    curl -XGET 'http://elastic_hostname:9200/_nodes/

    process?pretty=true'

    Verify cluster status is green

    curl -XGET 'http://elastic_hostname:9200/_cluster/

    health?pretty=true'

    Tip of the Day: 19 November 2016

    Edit file without less/vi it :

    # Set the “operation.type” as “operation.type=replace in file test.properties”

    sed -i 's|^operation\.type=.*|operation.type=replace|' test.properties

    Tip of the Day: 18 November 2016

    Big Data - Elasticsearch tip: Get tracks by jobRunnerId:

    curl -XPOST "http://bigdata1:9200/

    (Index_Name)/tracks/_search?pretty=true&size=10&from=0" -d'

    { "query": { "filtered": { "query": { "match_all": { } }, "filter": { "bool": { "must": [{ "term": { "jobRunnerId": 85560927007211972578520052831344758457 } }] } } } } }'

    Tip of the Day: 17 November 2016

    backup your Schema in Oracle : expdp (Admin User Name)/(Admin Password) DIRECTORY=DATA_PUMP_DIR DUMPFILE=xxxx.dmp LOGFILE=xxxx.log SCHEMAS=xxxxx;

    Tip of the Day: 16 November 2016

    DBA tip for today : if you have new Oracle Instance and you want it to start it up automatically after reboot you should do the following: cat /etc/oratab

    # This file is used by ORACLE utilities. It is created by root.sh

    # and updated by either Database Configuration Assistant while creating

    # a database or ASM Configuration Assistant while creating ASM instance.

    # A colon, ':', is used as the field terminator. A new line terminates

    # the entry. Lines beginning with a pound sign, '#', are comments.

    # Entries are of the form:

    # $ORACLE_SID:$ORACLE_HOME::

    # The first and second fields are the system identifier and home

    # directory of the database respectively. The third filed indicates

    # to the dbstart utility that the database should , "Y", or should not,

    # "N", be brought up at system boot time.

    # Multiple entries with the same $ORACLE_SID are not allowed.

    orcl:/u01/app/oracle/product/11.2.0/db_1:Y Last param should be 'Y'.

    Tip of the Day: 15 November 2016

    "jstat": A JVM statistics monitoring tool that displays performance statistics of a given JVM process with a specified sampling interval. "jstat" tool is distributed as part of the JDK package and represented by the \Progra~1\java\jdk*\bin\jstat.exe program file. "jstat" can be executed with the following syntax : jstat -gc -t 16773(the procses PID)

    Jmap command jmap -dump:format=b,file=Dump.hprof(the file name that will be created) 16773

    Tip of the Day: 14 November 2016

    Sometimes, df command reports that there is enough free space but system claims file-system is full. You need to check for the inode which identifies the file and its attributes on a file systems using the following command: $ df – i Then you can see how many inodes are in total and how many are free.

    in that exmaple the total Indoes for /dev/sda3 is 2984240 out of them 183048 are in used and 2801192 are free. if all the inodes were in used when trying to creatr new file in that mount i would have get 'No space left on device' even when df -k was returing that we have actaully space left

    What this site stand for ?

    Are you A backhand guy, working with Perl/Sh/ksh/Python scripts all days? if the answer is yes this is the place for you. . here you can buy fully and tested scripts and start showing off at work , be the hero !!