Jun 28, 2017

shell script to create a set of each 3 values within a range

I am trying to create a set of each 3 values within a range using Shell script.


Range of values     : 512 -885
Column difference: 12
Column increment: 3

    512 524 536
    515 527 539
    518 530 542
                 ......
    860 872 884
    863 875 513  --> Column 3 Reset
    866 878 516
    869 881 519
    872 884 522
    875 513 525  --> Column 2 Reset
    878 515 528
    881 518 531
    884 521 534
    513 524 537
    ....

Shell Script:

#!/bin/bash

start=512
end=885
incr=12
col1=$start
col2=$(($col1+$incr))
col3=$(($col2+$incr))
colincr=3
for z in {1..50}
do
    if [ $col1 -gt $end ]
    then
        col1=$(($(($col1 % $end))+$start-1))
    fi
    if [ $col2 -gt $end ]
    then
        col2=$(($(($col2 % $end))+$start-1))
    fi
    if [ $col3 -gt $end ]
    then
        col3=$(($(($col3 % $end))+$start-1))
    fi
    printf '%-4s%-4s%-4s\n' $col1 $col2 $col3
    col1=`expr $col1 + $colincr`
    col2=`expr $col2 + $colincr`
    col3=`expr $col3 + $colincr`
    
done





Jun 20, 2017

Hosting a PHP page from a yaws server using FastCGI on WINDOWS

If you are looking for a way to host or run a PHP page on YAWS server using PHP FastCGI process, just follow the below steps.


  • Place the PHP file/s in doc root folder
  • Change the yaws.conf file to redirect PHP script to run on FastCGI service.
                <server localhost>
                        port = 9009 
                        listen = 0.0.0.0
                        docroot = "C:\Program Files (x86)\Yaws-2.0.2/test"
                        auth_log = true
                        appmods = <cgi-bin, yaws_appmod_cgi>
                        php_handler = <fcgi, 127.0.0.1:54321>
                </server>

  • Start the YAWS server and confirm the errors.
  • Start the php FastCGI service.
    • To start on Windows: 
      • Download the XAMPP application from the below link and install it.
      • https://www.apachefriends.org/download.html
      • c:\xampp\php>php-cgi.exe -b 127.0.0.1:54321



Apr 20, 2017

amazon.in 503 service unavailable - oops Red Mi 4A sales

Amazon Red Mi 4A sales are huge. Due to this amazon.in website access got slowdown and during the peak time shown 503 services unavailable page from amazon.in


It's rush hour and traffic is piling up on that page. Please try again in a short while.If you were trying to place an order, it will not have been processed at this time.



Aug 11, 2015

rsh Permission denied error fix?

RSH command execution is throwing permission denied error as shown below.


host1> /usr/bin/rsh -l user1 host2 "ls /user1"
Permission denied.

Reason: host2 machine user1 home directory missing .rhosts file

FIX: Connect host2 machine, goto user1 home directory and create .rhosts file.
Provide the file permission as 0600 to file .rhosts and try RSH command now.. :)



May 15, 2015

How to get the unused or free IPs on linux machine?

 Inline format of the script:
lsof -nl >/tmp/lsof.log;rm -rf ~/freeIPs.log; for ip in `ip add list|grep -v "127.0.0\|::1\|0.0.0.0\|00:00:"|cut -d" " -f6|cut -d"/" -f1|grep -v qdisc|awk 'NF'`;do grep $ip /tmp/lsof.log > /dev/null; if [ $? != 0 ]; then echo $ip >> ~/freeIPs.log; fi; done; rm -rf /tmp/lsof.log;echo "Total IPs:`ip add list|grep -v "127.0.0\|::1\|0.0.0.0\|00:00:"|cut -d" " -f6|cut -d"/" -f1|grep -v qdisc|awk 'NF'|wc -l`"; echo "Free IPs:`wc -l ~/freeIPs.log`";

Script:

 lsof -nl >/tmp/lsof.log
 rm -rf ~/freeIPs.log
 for ip in `ip add list|grep -v "127.0.0\|::1\|0.0.0.0\|00:00:"|cut -d" " -f6|cut -d"/" -f1|grep -v qdisc|awk 'NF'`
 do 
     grep $ip /tmp/lsof.log > /dev/null
     if [ $? != 0 ]
    then 
          echo $ip >> ~/freeIPs.log
    fi
 done
 rm -rf  /tmp/lsof.log
 echo "Total IPs:`ip add list|grep -v "127.0.0\|::1\|0.0.0.0\|00:00:"|cut -d" " -f6|cut -d"/" -f1|grep -v qdisc|awk 'NF'|wc -l`";
 echo "Free IPs:`wc   -l ~/freeIPs.log`";

Sep 5, 2014

Sample in-line unix "for" loop command eaxmples.

home>for i in {307,306,311} ; do echo $i; done
output:
307
306
311

home> for i in {307,306,311} {374..376} ; do echo $i; done
output:
307
306
311
374
375
376