Sunday, 25 May 2014

Amazing Cool `C` Program

HI Guys, Output is really awesome. Try once ... Enjoy

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
void main() {
    int gd=DETECT,gm,i,j;
    int a;
    printf("%d%d",getmaxx(),getmaxy());

    initgraph(&gd,&gm,"C:\\tc\\bgi");
 
    for(j=1;j>0;j++) {
        for(i=0;i<=70;i++) {
            rectangle(0+2*i,0+4*i,0+5*i,20+4*i);
            setcolor(j);
            circle(300,400,5+i*2);
            setbkcolor(j-1);
           delay(100);
           circle(250,250,10+i);
           setbkcolor(j);
          //cleardevice();

      if(j>getmaxcolor())
          j=0;
         delay(50);
    }
    delay(400);
}
getch();
}

Saturday, 3 May 2014

BASH:: Store Data in File -> Check if Condition is TRUE -> Send that File as Attachment via Email.!

Basically, I am gathering data and storing the data into file "test.txt". I have specified the Day for which email will be sent to Specified Condition with "test.txt" file as an attachment. Every time I run that bash file it will append the data to an existing file.

USAGE:
             1) Install MUTT Mail Sending application in your machine.
                  I have tried with this command `sudo apt-get install mutt`

            2) Save the below given code with `.sh` extension.

            3) To Run this File type following code: `sh filename.sh`.

            4) Create one file named as "test.txt".

            5) Keep both 'test.txt' and `filename.sh` in same Directory(Demo).
                let path for file = /var/www/Demo/


#!/usr/bin/sh
{

now=$(date +"%m_%d_%Y")
today_date=$(date +"%A")

MAIL_BODY=$(cat <<'END_HEREDOC'
Hi Guest,
This is just a Test mail
END_HEREDOC
)

echo "The following commands executes at: " `date`;
echo " This is the Test Data that will stored in Test File";

  if [ "$today_date" = "Friday" ]; then
  echo "$MAIL_BODY" | mutt -a "/var/www/Demo/test.txt" -s "Mail Subject - $now" -- danish@bhea.co.in
  fi

  echo "\n\n";
} >> test.txt


NOTE: I have written this script for ubuntu system and it works fine. In case of other platform you have to check the dependency of your system.