GET CASH FROM YOUR SITE

affiliate program

GET CASH FROM YOUR WEBPAGE

Turn your valuable web site traffic into revenue. Work online and join our free money making partner program. We offer the most pay-per-click rate to help increase your income stream.

Join our income making program absolutely free and 100% risk free.

Sign Up...

FREE INVESTMENT PROGRAM

We created this money making system specifically for NO SETUP FEE methods, to make thousands, if not millions of dollars, without spending something.

Get revenue after you not working

Create many new revenue streams each and every minute. Get paid after you stop working or even retire at an young age with a broad money stream. Do this once and get revenue over and over again. It is best time to create astonishing new levels of money and success on the online.

A constant revenue generator

Imagine running of a something that never failed to generate revenue-flow. A free money program so amazingly profitable that you never had to work for a boss ever again!

Home - readbud - Get paid to read and rate articles! readbud pays you to read and rate interesting articles relevant to you. Visit www.readbud.com to start earning online!

Kamis, 30 April 2009

Shell Programming

Latihan 1: nama.sh

#!/bin/bash
echo –n “Masukkan Nama Lengkap Anda: “
read depan belakang
echo
echo “Haloo $depan $belakang”

1.Latihan 2: infosis.sh

#!/bin/bash
# Program Info Sistem
echo “Hostname : `hostname`”
echo “Date : `date|cut –d’ ’ –f2,3,6`”
echo “Time : `date|cut –d’ ’ –f4`”
echo “===================================================”
echo “`who`”
echo “===================================================”

2.Latihan 3: salin

#!/bin/bash
# Program salin biasa
cp $1 $2
echo “$1 sudah disalin ke $2”

3.Latihan 4: cek

#!/bin/bash
# Program cek file

if [ -f $1 ]
then
echo “$1 ada, dan suatu file biasa”
else
if [ -d $1 ]
then
echo “$1 ada, dan suatu directory”
else
echo “$1 tidak ada”
fi
fi

4.Latihan 5: salin2

#!/bin/bash
# Program salin lengkap
if [ $# = 0 ]
then
echo –n “masukkan file asal: “
read asal
echo –n “masukkan file tujuan: “
read tujuan
else
if [ $# = 1 ]
then
asal=$1
echo –n “masukkan file tujuan: “
read tujuan
else
asal=$1
tujuan=$2
fi
fi

if [ -f $asal ]
then
if [ -f $tujuan ]
then
echo –n “file $tujuan sudah ada, overwrite (y/n)? “
read jawab
if [ “$jawab” = y –o “$jawab” = Y ]
then
cp $asal $tujuan
echo “ $asal telah disalin ke $tujuan”
else
exit
fi
else
if [ -d $tujuan ]
then
echo “$tujuan adalah suatu directory”

else
cp $asal $tujuan
echo “$asal sukses disalin ke $tujuan”
fi
fi
else
echo “$asal tidak ada”
fi



5.Latihan 6: salam

#!/bin/bash
# Program Salam

jam=`date|cut –c12-13`

if [ $jam –ge 05 –a $jam –le 09 ]
then

clear
tput cup 11 30
tput blink
echo –n “Selamat Pagi”
read
tput sgr0
clear
else
if [ $jam –gt 09 –a $jam –le 15 ]
then
clear
tput cup 11 30
tput blink
echo –n “Selamat Siang”
read
tput sgr0
clear
else
if [ $jam –gt 15 –a $jam –le 18 ]
then
clear
tput cup 11 30
tput blink
echo –n “Selamat Sore”
read
tput sgr0
clear
else
clear
tput cup 11 30
tput blink
echo –n “Selamat Malam”
read
tput sgr0
clear
fi
fi
fi



6.Latihan 7: income

#!/bin/bash
# Program menghitung income
trap "" 1 2 3 15
clear
echo -n "Masukkan income Anda: "
read income

if [ $income -ge 0 -a $income -lt 100000 ]
then
rasio=0.1
elif
[ $income -ge 100000 -a $income -lt 250000 ]
then
rasio=0.25
else
rasio=0.35
fi
pajak=`bc <<**
scale=2
$rasio * $income
**`
hasil=`bc <<**
scale=2
$income -$pajak
**`
echo "Pajak yang harus dibayar: $pajak"
echo "Penghasilan bersih: $hasil"

7.Latihan 8: menu

#!/bin/bash
# Program Menu
trap "" 1 2 3 15
while :
do
clear
cat <<**
Menu Pilihan:
1. Jalankan Program Salam
2. Salin File
3. Hitung Income
4. Keluar
**
echo -n "Masukkan Pilihan Anda: "
read pilih
case $pilih in
1)salam ;;
2)salin ;;
3)income ;;
4)exit ;;
*)clear ; echo "Anda Salah Pilih" ;;
esac
echo ""
echo -n "Tekan Enter untuk Lanjut....!"
read
done

8.Latihan 9: loginmenu

#!/bin/bash
# Program Login

echo -n "Login: "
read login
stty -echo
echo -n "Password: "
read password
stty echo
pass=`echo "$password" | tr '[A-M][N-Z][a-m][n-z]' '[N-Z][A-M][n-z][a-m]'`
test1=`grep $login /data/datauser | cut -d':' -f1`
test2=`grep $login /data/datauser | cut -d':' -f2`
if [ "$test1" = "" ]
then
echo "Maaf, Anda tidak terdaftar"
elif
[ "$pass" != "$test2" ]
then
echo "Maaf, Password Anda Salah"
else
echo "Selamat, Anda Berhasil Masuk Program Kami....:)"
fi

9.Latihan 11: tambahuser

#!/bin/bash
# Program tambahuser
echo -n "Nama Login: "
read login
echo -n "Masukkan Password: "
stty -echo
read password
stty echo

test1=`grep $login /data/datauser | cut -d':' -f1`
if [ "$test1" = '' ]
then
pass=`echo "$password" | tr '[A-M][N-Z][a-m][n-z]' '[N-Z][A-M][n-z][a-m]'`
insert=${login}:$pass
echo "$insert" >> /data/datauser
echo "$login terdaftar"
else
echo "Maaf, Nama Login Sudah terdaftar"
fi


10.Latihan 11: ubahpasswd

#!/bin/bash
# Program mengubah password
if [ "$#" = 0 ]
then
echo "Usage: ubahpasswd [namalogin]"
exit
else
login=$1
fi

test1=`grep $login /data/datauser | cut -d':' -f1`
password=`grep $login /data/datauser | cut -d':' -f2`

if [ "$test1" = "" ]
then
echo "Maaf, $login tidak terdaftar"
exit
else
echo -n "Masukkan Password Awal: "
read pass1
fi

test1=`echo "$pass1"|tr '[A-M][N-Z][a-m][n-z]' '[N-Z][A-M][n-z][a-m]'`
if [ "$test1" != "$password" ]
then
echo "Maaf, Salah Password"
exit
else
echo -n "Masukkan Password baru: "
read pass2
echo -n "Masukkan kembali Password baru: "
read confirm
fi
if [ "$confirm" != "$pass2" ]
then
i=1
while [ $i -lt 3 ]
do
if [ "$confirm" != "$pass2" ]
then
echo ""
echo "Maaf, Password tidak cocok"
echo ""
echo -n "Masukkan Password baru: "
stty -echo
read pass2
stty echo

echo -n "Masukkan kembali Password baru: "
stty -echo
read confirm
stty echo

else
pass2=`echo $confirm|tr '[A-M][N-Z][a-m][n-z]' '[N-Z][A-M][n-z][a-m]'`
cat /data/datauser| grep -v $login > /data/datauser
echo "${login}:$pass2" >> /data/datauser
echo ""
echo "Password Anda telah berubah"
exit
fi
i=`expr $i + 1`
done
echo ""
echo "Maaf, habis waktu"
exit
else
pass2=`echo $confirm|tr '[A-M][N-Z][a-m][n-z]' '[N-Z][A-M][n-z][a-m]'`
cat /data/datauser | grep -v $login > /data/datauser
echo "${login}:$pass2" >> /data/datauser
echo ""
echo "Password Anda telah berubah"
fi

11.Latihan 12: hapususer

#!/bin/bash
# Program menghapus user
echo -n "Hapus user: "
read login
echo -n "Masukkan Password Root: "
stty -echo
read passroot
stty echo


pass=`echo "$passroot" | tr '[A-M][N-Z][a-m][n-z]' '[N-Z][A-M][n-z][a-m]'`
test1=`grep root /data/datauser | cut -d':' -f2`
nama=`grep $login /data/datauser | cut -d':' -f1`

if [ "$login" = "" ]
then
echo "User tidak terdaftar"
exit
elif [ "$login" = "root" ]
then
echo "Maaf, User:root tidak dapat dihapus"
exit
fi

if [ "$pass" != "$test1" ]
then echo "Maaf, Anda tidak berhak menghapus user"
else
cat /data/datauser|grep -v $login > /data/datauser
echo "User: $login dihapus"
fi

Tidak ada komentar:

Posting Komentar