Saturday, May 18, 2013

java Assignment 02

//=============SavingsAccount=======================

import java.util.Scanner;


public class SavingsAccount {

    private static double annualInterestRate = 0;
    private double savingsBalance;
    private int accountNumber;
    private String name;
    private String address;

    public int getAccountNumber() {
        return accountNumber;
    }

    public String getAddress() {
        return address;
    }

    public String getName() {
        return name;
    }
   

   

    public void addMonthlyInterest() {
        double thisMonthInterest = (annualInterestRate * savingsBalance) / (12*100);
        savingsBalance += thisMonthInterest;
    }

    static void modifyInterestRate() {
        System.out.println("Enter new annual interest rate:");
        annualInterestRate = (new Scanner(System.in)).nextInt();
    }

    public void setSavingsBalance(double amount) {
        this.savingsBalance = amount;
    }

  

    public double getSavingsBalance() {
        return savingsBalance;
    }
   
    public static double getAnnualInterestRate() {
        return annualInterestRate;
    }

  
   
    public SavingsAccount() {
//        createAcccount();
    }
   
    public void createAcccount(){
        System.out.println("\n>>>>>>>>>>> New Account details");
        System.out.print("\tAccount Number:");
        accountNumber = (new Scanner(System.in)).nextInt();

        System.out.print("\tName:");
        name = (new Scanner(System.in)).nextLine();

        System.out.print("\tAddress:");
        address = (new Scanner(System.in)).nextLine();

        System.out.print("\tInitial Savings Amount:");
        savingsBalance = (new Scanner(System.in)).nextDouble();
    }
   
    public void deposit(){
        System.out.println("Add deposite amount:");
        double amount=(new Scanner(System.in)).nextDouble();
        savingsBalance+=amount;
    }
   
    public void withdrawel(){
        System.out.println("Add withdrawel amount:");
        double amount=(new Scanner(System.in)).nextDouble();
        if (savingsBalance<amount){
            System.out.println("You have not enough balance in your account [balance= "+getSavingsBalance()+"]");
        }else{
            savingsBalance-=amount;
            System.out.println("Your money transaction was successfully");
        }
       
    }
   
     public void displayAccountDetails() {
        System.out.println("\n* * * * * * * * * * * * Bank Statment* * * * * * * * * * * * * * * * * * * *");
        System.out.println("\tName: " + getName() + "[ Account No: " + getAccountNumber() + "]");
        System.out.println("\tAddress: " + getAddress());
        System.out.printf("\tBalance: %8.2f", getSavingsBalance());
        System.out.println("\t" + "Current Interest rate: " + getAnnualInterestRate());
        System.out.println("* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *");

    }
   
   
   
   
}
//=============SavingsAccountTest=======================


import java.util.Scanner;


public class SavingsAccountTest {
    static int menuOption;
  
    public static void main(String[] args) {
       
         displayMainMenu();
       
         SavingsAccount saver=new SavingsAccount();
       
         do{
             if(menuOption==1){
                 saver.createAcccount();
             }else if(menuOption==2){
                 saver.deposit();
             }else if(menuOption==3){
                 saver.withdrawel();
             }else if(menuOption==4){
                 saver.displayAccountDetails();
             }else if(menuOption==5){
                 saver.modifyInterestRate();
             }else if(menuOption==6){
                saver.addMonthlyInterest();
             }
           
             displayMainMenu();
           
         }while(menuOption!=7);
       
       
     }
   
      public static void displayMainMenu() {
        System.out.println("\n========================== Main Menu ===============================================");
        System.out.println("\t 1- New Account");
        System.out.println("\t 2- Deposite");
        System.out.println("\t 3- Widdrawel");
         System.out.println("\t 4- Bank Statment");
        System.out.println("\t 5- Change Annual Interest Rate");
        System.out.println("\t 6- Add month interest to a Account");
        System.out.println("\t 7-exit ");
        System.out.println("====================================================================================\n");
        System.out.print("Choose :");
        menuOption=(new Scanner(System.in)).nextInt();
    }
  
}

Wednesday, February 20, 2013

The best file recovery software( File Scavenger® )



File Scavenger® - Data Recovery Utility



File Scavenger® Version 4 is a file "undelete" and data recovery utility for Windows® 8, 7, Vista, Server 2003, XP and 2000. File Scavenger® can recover files that have been accidentally deleted (including files removed from the Recycle Bin, in a DOS window, from a network drive, from Windows Explorer with the SHIFT key held down) provided that recovery is attempted before the files are permanently overwritten by new data. File Scavenger® supports both basic and dynamic disks, NTFS compression, alternate data streams, sparse files, Unicode filenames, etc. Except in severe cases, both the file and the folder path leading to the file can be recovered.
File Scavenger® can also recover files from a reformatted or corrupted volume even when the volume has been deleted and its original position and size are unknown. File Scavenger® can scan an entire physical hard drive to look for traces of defunct volumes.
File Scavenger® uses advanced algorithms to handle disks with bad sectors and badly corrupted partitions. It can be installed on a hard drive or run from a portable storage device such as a memory card, removable drive, or CD. To run File Scavenger®, you must log on as a system administrator to the computer where data recovery is intended.
Files can only be restored if the disk areas allocated to the files have not been overwritten by new data. All recovered files should be validated for the integrity of the recovered data.

http://www.quetek.com/prod02.htm


Thursday, November 3, 2011

Samba Standalone Server

I planned to held online practical exams for students who must save their result data on remote samba server.
This tutorial explains the installation of a Samba fileserver on Ubuntu 10.10 and how to configure it to share files over the SMB protocol as well as how to add users. Samba is configured as a standalone server, not as a domain controller. In the resulting setup, every user has his own home directory accessible via the SMB protocol and all users have a shared directory with read-/write access.
I do not issue any guarantee that this will work for you!

1 Preliminary Note

I'm using an Ubuntu 10.10 system here with the hostname server1.example.com and the IP address 192.168.0.100.
I'm running all the steps in this tutorial with root privileges, so make sure you're logged in as root:
sudo su

2 Installing Samba

Connect to your server on the shell and install the Samba packages:
aptitude install libcups2 samba samba-common
Edit the smb.conf file:
vi /etc/samba/smb.conf
In the global section, remove the "#" at the beginning of the line security = user so that it looks like this:
[...]
# "security = user" is always a good idea. This will require a Unix account
# in this server for every user accessing the server. See
# /usr/share/doc/samba-doc/htmldocs/Samba3-HOWTO/ServerType.html
# in the samba-doc package for details.
   security = user
[...]
This enables Linux system users to log in to the Samba server.
Close the file and restart Samba:
/etc/init.d/smbd restart

3 Adding Samba Shares

Now I will add a share that is accessible by all users.
Create the directory for sharing the files and change the group to the users group:
mkdir -p /home/shares/allusers
chown -R root:users /home/shares/allusers/
chmod -R ug+rwx,o+rx-w /home/shares/allusers/
At the end of the file /etc/samba/smb.conf add the following lines:
vi /etc/samba/smb.conf
[...]
[allusers]
  comment = All Users
  path = /home/shares/allusers
  valid users = @users
  force group = users
  create mask = 0660
  directory mask = 0771
  writable = yes
If you want all users to be able to read and write to their home directories via Samba, add the following lines to /etc/samba/smb.conf:
[...]
[homes]
   comment = Home Directories
   browseable = no
   valid users = %S
   writable = yes
   create mask = 0700
   directory mask = 0700
Now we restart Samba:
/etc/init.d/smbd restart

4 Adding And Managing Users

In this example, I will add a user named tom. You can add as many users as you need in the same way, just replace the username tom with the desired username in the commands.
useradd tom -m -G users
Set a password for tom in the Linux system user database. If the user tom should not be able to log in to the Linux system, skip this step.
passwd tom
-> Enter the password for the new user.
Now add the user to the Samba user database:
smbpasswd -a tom
-> Enter the password for the new user.
Now you should be able to log in from your Windows workstation with the file explorer (address is \\192.168.0.100 or \\192.168.0.100\tom for tom's home directory) using the username tom and the chosen password and store files on the Linux server either in tom's home directory or in the public shared directory.
Bulk user Creating script
#!/bin/bash
#
# Ensure that root is running the script.
##
WHOAMI=`/usr/bin/whoami`
if [ $WHOAMI != "root" ]; then
echo "You must be root to add news users!"
exit 1
fi
#
clear
NEW_USERS="/home/names.txt"
 
cat ${NEW_USERS} | \
while read USER GROUP SMBPASS ; do
   
   groupadd ${GROUP} 2> /dev/null
   adduser ${USER} -g ${GROUP}
 
   (echo $SMBPASS; echo $SMBPASS) | passwd --stdin ${USER} > /dev/null
   echo Added user ${USER}
 
   smbpasswd -e ${USER} -w ${SMBPASS} > /dev/null
   (echo $SMBPASS; echo $SMBPASS) | smbpasswd -as ${USER}
   echo -e "${USER} = ${USER}" >> /etc/samba/smbusers
done
I was modified above codes related to me as bellow
#!/bin/bash
#
# Ensure that root is running the script.
##
WHOAMI=`/usr/bin/whoami`
if [ $WHOAMI != "root" ]; then
echo "You must be root to add news users!"
exit 1
fi
#
clear
NEW_USERS="/root/samba/userlist"
cat ${NEW_USERS} | \
while read USER GROUP SMBPASS ; do
echo "--->${USER} ${GROUP} ${SMBPASS} ---"
echo "useradd ${USER} -m -G ${GROUP}"
useradd ${USER} -m -G ${GROUP}
echo "(echo $SMBPASS;echo $SMBPASS) | smbpasswd -as ${USER}"
(echo "$SMBPASS"; echo "$SMBPASS") | smbpasswd -as ${USER}
done
delete bulk user
#!/bin/bash
clear
NEW_USERS="/root/samba/userlist"
cat ${NEW_USERS} | \
while read USER GROUP SMBPASS ; do
echo "--->${USER} ${GROUP} ${SMBPASS} ---"
smbpasswd -d ${USER}
echo "smbpasswd -d ${USER}"
echo "userdel -r ${USER}"
userdel -r ${USER}
done
sample userlist file
10751332 users 10751332
10752762 users 10752762
10850951 users 10850951
10852593 users 10852593
109067664 users 109067664
109067727 users 109067727
“users” unix user group . all users on belongs to users group.
For clear previous window authentication use bellow commds
Solution
Click on Start > Run
Enter cmd in he textbox
Enter net use * /delete in the dos box.
useradd tom -m -G users
(echo “sss”; echo “sss”) | smbpasswd -as tom


 N2N copy command , this is used for copy files to multiple folders...

echo /home/distinationfolder* |xargs -n 1 cp -rf /root/Sourcefolder/*

  To configure Nginx for a Laravel application located within a subfolder, a  location  block is required to handle requests to that specifi...