Kamis, 02 Desember 2010

Okay i will to show you how to find file with mp3 type or png type n etc. the script is simple. Lets do it:

  1. find all file with mp3 type. You just type in your terminal ---> find *.mp3
  2. find all file with png type. You just type in your terminal ---> find *.png
  3. find all file with avi type. You just type in your terminal ---> find *.avi

okay, thats very simple. you can modify thats script with your idea. thanks for come in my blog.

=-=-=-=-=
Powered by Blogilo

This tutorial explain you how to make file with lowercase exchange to Uppercase. This is the scenario.

  • We have a file with lowercase in text. in this time, my file name is `aris` where in file have a `cakep` text.
  • I want to text `cakep` in aris file change to Uppercase `CAKEP`

Okay i thinks that's simple scenario, so we already to the script

#!/bin/bash

# Mengambil nama file

echo -n "Enter File Name : "

read fileName

# script ini untuk men-cek apakah file yg di maksud ada

if [ ! -f $fileName ]; then

echo "Filename $fileName tidak ada, cek kembali"

exit 1

fi

# Script untuk melakukan perubahan dari lowwercase ke Uppercase dengan perintah tr

tr '[a-z]' '[A-Z]' < $fileName

in that script i use indonesia language for to explain. but don't worry i have the address of original script. You can follow this address for original script http://www.cyberciti.biz/faq/linux-unix-shell-programming-converting-lowercase-uppercase/

okay thanks for comming

=-=-=-=-=
Powered by Blogilo

Rabu, 01 Desember 2010

Langkah-langkahnya:
  1. cd Documents/ -> perintah untuk berpindah ke direktori Documents agar hasil download bisa berada pada direktori tersebut.
  2. wget -c http://fennypotter.files.wordpress.com/2010/12/johnwileyandsonswebengineering.pdf -> wget adalah perintah untuk download, -c adalah perintah atau option dari wget yg berfungsi untuk menyambung kembali download yang terputus ataupun tertunda, http://fennypotter.files.wordpress.com/2010/12/johnwileyandsonswebengineering.pdf adalah alamat dari file yang kita download
Tutorial ini tentu sudah banyak yang menulis, namun ini saya buat jika nanti saya sudah tua dan penyakit pikun menyerang. Semoga bermanfaat.
=-=-=-=-=

Powered by Blogilo

Kamis, 25 November 2010

Pernahkah kita semua menghitung berapa tabung oksigen yang di butuhkan. Pernahkah kita menghitung berapa harga sehat tubuh kita?. Hitunglah itu semua hingga kita meninggal, secara normal usia 60 s.d. 70 tahun. berap dolar yang harus kita bayar untuk dua hal tersebut. Takan Ada, sebuah lagu dari amanda yang terilhami dari surat Ar Rahman yang menggambarkan bahwasannya tidak akan ada yang dapat menggantikan nikmat yang telah Tuhan berikan kepada kita. [renungan]

=-=-=-=-=
Powered by Blogilo

Rabu, 24 November 2010

Shell Script selain digunakan untuk membuat aplikasi yang berhubungan dengan sistem operasi, juga dapat digunakan untuk membuat software aplikasi berbasis web ataupun aplikasi untuk web. Dalam Konsepnya, shell dapat di masukan dengan berbagai macam bahasa pemrograman yang mana bahasa pemrograman tersebut harus memenuhi syarat yaitu mempunyai output atau keluaran.

Tentu saja bahasa pemrograman yang saya kenal rata-rata memiliki suatu keluaran. seperti C, Java, Gambas, Lazarus dan sebagainya. Dalam posting kali ini saya akan memberikan beberapa contoh script dari pemrograman shell untuk membangun suatu aplikasi.


Program #1

Beri nama file ini tanpa ekstensi. contoh cg7.

#!/bin/sh

echo "Content-type: text/html\n"

# read in our parameters

CMD=`echo "$QUERY_STRING" | sed -n 's/^.*cmd=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"`

FOLDER=`echo "$QUERY_STRING" | sed -n 's/^.*folder=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"| sed "s/%2F/\//g"`

# our html header

echo "<html>"

echo "<head><title>Hello CGI</title></head>"

echo "<body>"

# test if any parameters were passed

if [ $CMD ]

then

case "$CMD" in

ifconfig)

echo "Output of ifconfig :<pre>"

/sbin/ifconfig

echo "</pre>"

;;

uname)

echo "Output of uname -a :<pre>"

/bin/uname -a

echo "</pre>"

;;

dmesg)

echo "Output of dmesg :<pre>"

/bin/dmesg

echo "</pre>"

;;

ls)

echo "Output of ls $FOLDER :<pre>"

/bin/ls -la "$FOLDER"

echo "</pre>"

;;

*)

echo "Unknown command $CMD<br>"

;;

esac

fi

# print out the form

echo "Choose which command you want to run"

echo "<form method=get>"

echo "<input type=radio name=cmd value=ifconfig checked> ifconfig <br>"

echo "<input type=radio name=cmd value=uname> uname -a <br>"

echo "<input type=radio name=cmd value=dmesg> dmesg <br>"

echo "<input type=radio name=cmd value=ls> ls -- folder <input type=text name=folder value=/home><br>"

echo "<input type=submit>"

echo "</form>"

echo "</body>"

echo "</html>"

Untuk menjalankan program di atas saya mengaktifkan aplikasi xampp saya dan menaruh nya pada directori /opt/lampp/cgi-bin. Sebelumnya pastikan file di atas telah anda beri hak akses dengan chmod +x.

Program #2

Program di bawah ini adalah program untuk membuat aplikasi form. Berikut scriptnya.

#!/bin/bash

echo "Content-type: text/html"

echo ""

echo '<html>'

echo '<head>'

echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">'

echo '<title>Form Example</title>'

echo '</head>'

echo '<body>'

echo "<form method=GET action=\"${SCRIPT}\">"\

'<table nowrap>'\

'<tr><td>Input</TD><TD><input type="text" name="val_x" size=12></td></tr>'\

'<tr><td>Section</td><td><input type="text" name="val_y" size=12 value=""></td>'\

'</tr></table>'

echo '<input type="radio" name="val_z" value="1" checked> Option 1<br>'\

'<input type="radio" name="val_z" value="2"> Option 2<br>'\

'<input type="radio" name="val_z" value="3"> Option 3'

echo '<br><input type="submit" value="Process Form">'\

'<input type="reset" value="Reset"></form>'

# Make sure we have been invoked properly.

if [ "$REQUEST_METHOD" != "GET" ]; then

echo "<hr>Script Error:"\

"<br>Usage error, cannot complete request, REQUEST_METHOD!=GET."\

"<br>Check your FORM declaration and be sure to use METHOD=\"GET\".<hr>"

exit 1

fi

#If no search arguments, exit gracefully now.

if [ -z "$QUERY_STRING" ]; then

exit 0

else

# No looping this time, just extract the data you are looking for with sed:

XX=`echo "$QUERY_STRING" | sed -n 's/^.*val_x=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"`

YY=`echo "$QUERY_STRING" | sed -n 's/^.*val_y=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"`

ZZ=`echo "$QUERY_STRING" | sed -n 's/^.*val_z=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"`

echo "val_x: " $XX

echo '<br>'

echo "val_y: " $YY

echo '<br>'

echo "val_z: " $ZZ

fi

echo '</body>'

echo '</html>'

exit 0Seperti program #1 taruh program tersebut pada direktori /opt/lampp/cgi-bin.
Kalo kita mengamati 2 skrip program di atas, hanya menggunakan bahasa pemrograman html seperti biasa. Dan sangat jelas di 2 skrip program di atas menggunakan perintah echo. perhatikan skrip berikut [ echo "Content-type: text/html" ], skrip tersebut menunjukan jika konten dari skrip yang akan di jalankan bertipe html dan jika di jalankan akan menjalankan skrip dari html di atas melalui perintah echo. Berikut screen shoot nya dari program #2



Bagaimana mudah bukan belajar pemrograman shell? bahkan kita dapat memasukan berbagai macam bahasa pemrograman dalam satu skrip. Selanjutnya akan saya usahakan memberikan contoh-contoh program yang lain. Terima Kasih.