Showing posts with label shell. Show all posts
Showing posts with label shell. Show all posts

May 27, 2008

1

Fluxbox: Setting Sound Keyboard Control

Well one of my friend, piju - asking me about how do I control my sound volume on my fluxbox. As he has more experience than me, so maybe he have his own way on controlling sound volume on his Fluxbox. But for me, it's quite simple.

At First I wanted to set the FN key to control sound, but as I search on the google, no other tutorial successfully set the FN+VolDown/VolUp yet. The FN key isnt being map. So I replace FN laptop's Keyboard key with "Windows Key". Here is how to set it up:

  • Open up your shortcut key's file: (On terminal type)
nano ~/.fluxbox/keys
  • then add the following line at the end of file:
mod4 Up: ExecCommand amixer set Master 1%+
mod4 Down: ExecCommand amixer set Master 1%-
  • I hope from here you can get an idea on how to mute and do any other things with sound with the shortcut utility.
I hope this will help Fluxbox user to control sound much better than before. Some other method, you could just install other application GTK based to control your sound.

Bookmark This Article:

Feed Me Digg this Stumble Upon this Send this Reddit this Add to Technorati Favorites Directory of Computers/Tech Blogs Programming Blogs - BlogCatalog Blog Directory

Your Ad Here

Apr 18, 2008

4

Update: Numbers Combination Creator

I did make a post about my script to generate numbers combination depends on user input to set the number of digits a few weeks ago. And I was thinking to make it more clean and user friendly after received a comments from "Pak Leman".

So here is the update of the scripts. The script will asked user to input the digits of combination to generate. And will asked user to give the output filename. So no more "sh script 8 > huhu.txt" . To run the script just run "sh script" and it will ask you all the details using script.

So here is the full codes of the script, and also pictures of the output:

#!/bin/sh
echo "Please give the digits for combinations[8-63]: \c"
read digit
echo "Please type the output file name: \c"
read OUTFILE

FINISH=`expr "10^"$digit"" | bc -l`

if [ $digit -lt 8 -o $digit -gt 64 ]
then
clear
echo "The digit you specify is ' $digit '. "
echo "Please enter a valid digit [8-63]: \c"
read digit
else
break
fi

COUNT="-1"
while [ $COUNT != `expr $FINISH - 1` ] ; do
COUNT=`expr $COUNT + 1`
printf "%+"$digit"s\n" $COUNT | sed s^\ ^0^g >> $OUTFILE
done

So any opinion on how to improve the script are most welcome. Somehow the script still allow digits more than 63. Still looking forward to repair this script. Any thought or advise are welcome. Please drop some comments.

Bookmark This Article:

Feed Me Digg this Stumble Upon this Send this Reddit this Add to Technorati Favorites Directory of Computers/Tech Blogs Programming Blogs - BlogCatalog Blog Directory

Your Ad Here

Apr 14, 2008

7

Script to generate Numbers Combination

This is a script to generate combinations of numbers from 0-9 depends on how many digits you specify when running the scripts. It's a simple script that took me 5 minutes to write. Plus I got the idea of writing this script from one of my friend.

This script is useful for those who wants to generate a wordlist for bruteforce. Here is the scripts:

#!/bin/sh
# Usage:
# sh [script name] [digits specify] > [output file] &
digit=$1
FINISH=`expr "10^"$digit"" | bc -l`
COUNT="-1"
while [ $COUNT != $FINISH ] ; do
COUNT=`expr $COUNT + 1`
printf "%+"$digit"s\n" $COUNT | sed s^\ ^0^g
done
Why do I only write scripts for numbers combination? The answer is simple, if I wrote a script that will create a combination of all ascii letters, then it will be too much for a single machine to generate and also will took you a long long time to generate.

If you want to calculate how much time it will take to generate a combination of digits with quantity of letters(ascii) then you can do calculation on this website, Generator Calculator.

Look at the time needed to generate a full ascii password list. It's not worth your time to do that. If you ever need a full ascii generator, than you can download it right here.

* The script will be update soon to be more user friendly.

Bookmark This Article:

Feed Me Digg this Stumble Upon this Send this Reddit this Add to Technorati Favorites Directory of Computers/Tech Blogs Programming Blogs - BlogCatalog Blog Directory

Your Ad Here

Apr 12, 2008

3

LOLcode Programming


I woke up when my girlfriend sms me "morning" . So I go to my laptop and start my day with surfing. So I start surfing on my new router's modification. But I found something interesting on one of the open blog on the net, It's called LOLCode.

So I start wondering what is LOLcode is all about, I start reading and go read more on the link given. Found out, that LOLcode is actually fun to play with. It's a silly programming based on 1337-speak(gamers/hackers slang)

There is an official site for LOLcode. This language has turned into a Programming Language called LOLCode for which there are already at least TWO .NET implementations. So here is the LOLcode example:


HAI
CAN HAS STDIO?
I HAS A VAR
IM IN YR LOOP
UP VAR!!1
VISIBLE VAR
IZ VAR BIGGER THAN 10? KTHXBYE
IM OUTTA YR LOOP
KTHXBYE
Funny isnt it? maybe you would like to try it for your self, but is has too many keyword that hard to understand unless someone explain it to you. So happy coding guys~!

Bookmark This Article:

Feed Me Digg this Stumble Upon this Send this Reddit this Add to Technorati Favorites Directory of Computers/Tech Blogs Programming Blogs - BlogCatalog Blog Directory

Your Ad Here

Apr 6, 2008

2

Symlink can be handfull for webserver

I just finish chatting with one of my friend who is currently using ubuntu linux. I was helping him to manage his harddisk space as he is running out of space for his 'root web folder' which was define in apache2.conf. So he in the middle of making decision either wanted to clear everything and redo the config of apache root web folder to point to another hardisk or just find another way to make it possible to add more files into his webfolder.

Here is the situation:
/www/ --- space used 10.9gb /11gb
/share/ --- space used 46gb / 300gb

So my suggestion to him is to do symlink from /share/ folder to the /www/ so that he could used space from share and extend his www size by symlink the folder. So, here is the way to make a symlink :

syntax :

  • ln [option] [exact folder/files location] [link location]
And from this example, my friend's exact location is "/share/extended/" and he wanted to put it inside "/www/". So the sommand should be like this:
  • ln -s /share/extended /www/
  • explaination of -s : use for symbolic links instead of hard link. It is safer cause it will not effect the exact location if any wrong doing happened such as wrongly delete the files and etc.
  • but if you would like to make a hard link, apply the command without -s .
For more information about making a symbolic link(symlink) please refer to the man pages of 'ln' command. ln man page

How do you know your folder has being successfully link to the destination you specified? simple, just list the destination folder, and try to find a folder with '@' at the back, for example: extended@ .

Bookmark This Article:

Feed Me Digg this Stumble Upon this Send this Reddit this Add to Technorati Favorites Directory of Computers/Tech Blogs Programming Blogs - BlogCatalog Blog Directory

Your Ad Here

Apr 2, 2008

0

2nd shell scripting (Basic)

erm, this morning while I arrived at my office, the internet connection was down. It was down because of the electricity trip last night while we do the network cabling at the office. So without internet i wonder what else can i do.

So I started to open up text editor, and try do make some script. I remember 'slamdunk' once told me, the way to troubleshoot network problem and he using shell script to make his life easier. So I try to recall back his way of doing it, and here is what I come up with:

#!/bin/bash
#
#$1 is an IP address
#
clear
x=1
y=1
while :; do
echo "$x)---> Ping Internet Protocol : $1 --->"
echo " <-------- Ping Reply is => `ping -c1 -s1 $1 | grep "1 \
received" | cut -d "," -f2` \
<--------||" x=`expr $x + $y` echo " " sleep 10 done
So here is what i did and the outcome is nice. I only see if the destination is reachable or not instead of all the ttl, ms and etc. So all I output is only the one I would like to get from the ping command.

After finish writing this script, I try it on my laptop to ping google and it works where i only manage to see the output either reachable or unreachable. :) Nice one for beginner right?

how to use this script? you just need to write sh [script] [ip/url]

Bookmark This Article:

Feed Me Digg this Stumble Upon this Send this Reddit this Add to Technorati Favorites Directory of Computers/Tech Blogs Programming Blogs - BlogCatalog Blog Directory

Your Ad Here

Mar 30, 2008

0

LINUX: Auto check the Zone Edit every 60 sec

Erm, one of my friend ask me how can he make an auto check to the zone edit for every 60 secs by using cron. My answer is simple.. I dont know how to use cron. haha.. so I'm thinking sumthing else, I come out with a script which I do write a simple one just to make it check to zone edit for every 60 seconds.

Here is my script looks like:

#!/bin/bash
#
#
#
#

while :;do echo "=========================================================" ;
wget -q -O - --http-user=username --http-passwd=password \
'http://dynamic.zoneedit.com/auth/dynamic.html?host=www.mydomain.com';
sleep 60;
done

#hehe.. mungkin saja berjaya.


How to apply this script to run every time you load your linux? Simple, here is the steps I would make:
  • mkdir ~/.script ; cd ~/.script
  • wget http://portalpsis.net/upload/files/zoneedit
  • ln -s ~/.script/zoneedit /usr/bin
  • Now we need to edit our rc.local so that the script will load on startup.
  • sudo gedit /etc/rc.local
  • and add this line before "exit 0" ---> /usr/bin/zoneedit &
So now you will have this script load on every session you make. To check if it's succesfully loaded, please reboot you machine and login back.. Once login successful, open up terminal and run "ps aux | grep zonedit" and you will see an output with pid of the script running.

This one made for my friend Sinzmanual. :)

ps:- the bold part in the script need changes to be able to check to zone edit. use your own usernames,password and domain.

Bookmark This Article:

Feed Me Digg this Stumble Upon this Send this Reddit this Add to Technorati Favorites Directory of Computers/Tech Blogs Programming Blogs - BlogCatalog Blog Directory

Your Ad Here

Mar 27, 2008

0

LINUX: Coloring your zsh shell in ubuntu

Some people will be bored looking at colorless terminal as i usually look. I do 50% of my laptop by using my terminal(CLI) on my Ubuntu 7.10 Gutsy Gibbon. I used to use bash shell a few weeks ago and bash do have some coloring on the shell, but still a lil bit boring.

But recently I change myself to zsh shell to do more shell programming. It's not the best shell for script/programming, but I get/read a lot of feedback from other linux user that this shell is suitable for shell scripting/programming.

So I this is simple tutorial on how to color your terminal to your need and make it a litle bit interesting to look at, so maybe you can spend more time to do you programming :P

First of all, you need to know the color code for shell, here is the list:

  • Choices : red, green, yellow, blue, magenta, cyan and white. The color codes for this are 30 (black), 31(red), 32 (green), 33 (yellow), 34 (blue), 35 ( magenta), 36 (cyan), 37 (white).
So now for coloring the zsh shell, you need to make a file name ".zshrc" on user's home folder. you can create the file by this command:
  • touch ~/.zshrc
After that, you need to do a litle coding to make your shell prompt. Open up your .zshrc that you just created by using any text editor of your choices. As for me, I prefer to use nano. So here is my command:
  • nano ~/.bashrc
This will open the .zshrc file inside your terminal, it is plain file without any text inside. So all you have to do is write the code. Here is some tips:
  • for prompt option you just need to add "PROMPT=" command inside .zshrc but if you would like to make some differences, you can try to do it on the right side by using this "RPROMPT="
  • here is some variable which will be recognized by shell: (%n)Username , (%B , %b)Bold text, (%~)Current Directory, (%U , %u)Underline, (%m)Machine name, (%h)Number of shell's history, (%t)Time and etc.
  • For coloring you have to use this %{\e[0;31m%} , and by changing number "31" you can change the color by the code given earlier.
  • So here is a simple example to create your prompt: paste this inside your .zshrc
    • PROMPT=$'%{\e[0;32m%}%UTell zsh what to do!%u %{\e[0m%}'
    • Save and exit.
    • Restart your terminal and you will see your prompt changing to :
      • Tell zsh what to do!
  • So you can try yourself to color up your terminal shell by writing your own .zshrc ~!
here is my screenshots:After applying the .zshrc in home folder

Bookmark This Article:

Feed Me Digg this Stumble Upon this Send this Reddit this Add to Technorati Favorites Directory of Computers/Tech Blogs Programming Blogs - BlogCatalog Blog Directory

Your Ad Here