dd if=/dev/mem bs=1k skip=768 count=256 2>/dev/null | strings -n 8
skip to main |
skip to sidebar
1 #!/bin/bash
2
3 echo babbbbil 12223 | awk '{for(i=1;i<=NF;i++){if($i ~ "122"){print $i;i=NF+1}}}'
4
This piece of awk code will go through all the fields and look for pattern "122" and print them. The "i=NF+1" will work like "break;" in C which will make awk to stop printing after the first hit. Happy Awk'ing ;)
You can perform the following operations from the shell
1 #!/bin/bash
2
3 router_ip=192.168.0.1
4 username="admin"
5 password="CHANGE-ME"
6
7 debug_url="http://$router_ip/setup.cgi?todo=debug"
8 status_url="http://$router_ip/setup.cgi?next_file=s_status.htm"
9 connection_url="http://$router_ip/setup.cgi?next_file=st_poe.htm"
10 disconnect_url="http://$router_ip/setup.cgi?todo=disconnect&next_file=st_poe.htm"
11 connect_url="http://$router_ip/setup.cgi?todo=connect&next_file=st_poe.htm"
12
13
14 RED='\e[1;31m'
15 CYAN='\e[1;36m'
16 NC='\e[0m' # No Color
17
18 tmp_file="/tmp/babil-router.info"
19 sleep_time=3
20
21
22 function clean_up()
23 {
24 rm -f $tmp_file
25 }
26
27 function reboot_router()
28 {
29 report=`wget -q --user $username --password $password $debug_url -O /dev/null`
30 echo "[+] $report"
31 sleep 2
32 (sleep 2; echo "reboot"; sleep 2) | telnet $router_ip
33 }
34
35
36 function ip()
37 {
38 #curl --basic --user $username:$password $status_url 2>/dev/null | sed -e :a -e 's/<[^>]*>//g;/<;/N;//ba' > $tmp_file
39 wget -q --user $username --password $password $status_url -O - | sed -e :a -e 's/<[^>]*>//g;/<;/N;//ba' > $tmp_file
40
41 c=1
42 while read line
43 do
44 #echo "$c $line"
45 if [[ $c == 71 ]];then
46 echo -e "[+] outbound ip : ${RED} $line ${NC}"
47
48 elif [[ $c == 83 ]];then
49 echo -e "[+] gateway ip : ${RED} $line ${NC}"
50
51 fi
52
53 c=$((c+1))
54
55 done < $tmp_file
56 clean_up
57 }
58
59
60 function stat()
61 {
62
63 ip
64
65 #curl --basic --user $username:$password $connection_url 2>/dev/null | sed -e :a -e 's/<[^>]*>//g;/<;/N;//ba' > $tmp_file
66 wget -q --user $username --password $password $connection_url -O - | sed -e :a -e 's/<[^>]*>//g;/<;/N;//ba' > $tmp_file
67
68 c=1
69 while read line
70 do
71 #echo "$c $line"
72 if [[ $c == 61 ]];then
73 echo -e "[+] duration : ${RED} $line ${NC}"
74
75 elif [[ $c == 65 ]];then
76 echo -e "[+] status : ${RED} $line ${NC}"
77
78 fi
79
80 c=$((c+1))
81
82 done < $tmp_file
83
84 clean_up
85
86 }
87
88
89 function connect()
90 {
91 echo -n "[+] connecting "
92 #curl --basic --user $username:$password $connect_url 2>/dev/null | sed -e :a -e 's/<[^>]*>//g;/<;/N;//ba' > $tmp_file
93 wget -q --user $username --password $password $connect_url -O - | sed -e :a -e 's/<[^>]*>//g;/<;/N;//ba' > $tmp_file
94 for ((i=0;i<$sleep_time;i++))
95 do
96 echo -n "."
97 sleep 1
98 done
99
100 echo
101 stat
102 }
103
104
105 function disconnect()
106 {
107 echo -n "[+] disconnecting "
108 #curl --basic --user $username:$password $disconnect_url 2>/dev/null | sed -e :a -e 's/<[^>]*>//g;/<;/N;//ba' > $tmp_file
109 wget -q --user $username --password $password $disconnect_url -O - | sed -e :a -e 's/<[^>]*>//g;/<;/N;//ba' > $tmp_file
110 for ((i=0;i<$sleep_time;i++))
111 do
112 echo -n "."
113 sleep 1
114 done
115
116 echo
117 stat
118 }
119
120 case "$1" in
121
122 connect)
123 echo
124 connect
125 echo
126 ;;
127
128 disconnect)
129 echo
130 disconnect
131 echo
132 ;;
133
134 stat)
135 echo
136 stat
137 echo
138 ;;
139 reboot)
140 echo
141 reboot_router
142 echo
143 ;;
144 reconnect)
145 echo
146 connect
147 echo
148 disconnect
149 echo
150 ;;
151 *)
152 echo
153 echo -e "[+] usage: `basename $0` { ${RED}connect | disconnect | reconnect | stat | reboot${NC} }"
154 echo
155 exit 1
156 ;;
157
158 esac
159
160
After performing a very starnge (and stupid) migration from kubuntu-intrepid to edubuntu-intrepid, then to xbunbu-intrepid and lastly to original Ubuntu-intrepid, my skype sound was blocking all other audio softwares from using my sound card while in a skype-call (basically no software mixing).
I seem to have found two solutions for the problem after suffering and searching for almost a day:
solution-1:: making sure you have pulse-audio installed [1]
$ sudo rm -r ~/.pulse ~/.asound* /etc/asound.conf
solution-2:: create a dummy "skype" device for alsa [2]
pcm.skype {
type asym
playback.pcm "skypeout"
capture.pcm "skypein"
}
pcm.skypein {
# Convert from 8-bit unsigned mono (default format set by aoss when
# /dev/dsp is opened) to 16-bit signed stereo (expected by dsnoop)
#
# We can't just use a "plug" plugin because although the open will
# succeed, the buffer sizes will be wrong and we'll hear no sound at
# all.
type route
slave {
pcm "skypedsnoop"
format S16_LE
}
ttable {
0 {0 0.5}
1 {0 0.5}
}
}
pcm.skypeout {
# Just pass this on to the system dmix
type plug
slave {
pcm "dmix"
}
}
pcm.skypedsnoop {
type dsnoop
ipc_key 1133
slave {
# "Magic" buffer values to get skype audio to work
# If these are not set, opening /dev/dsp succeeds but no sound
# will be heard. According to the alsa developers this is due
# to skype abusing the OSS API.
pcm "hw:0,0"
period_size 256
periods 16
buffer_size 16384
}
bindings {
0 0
}
}
======================================================================
[1] http://ubuntuforums.org/showthread.php?t=789578&highlight=pulseaudio+perfect
[2] http://ubuntuforums.org/showthread.php?t=44753&page=15
mplayer -vc null -vo null -ao pcm -benchmark test.avi
Friday, December 12, 2008
Thursday, November 27, 2008
Awk pattern matching over a particular field
1 #!/bin/bash
2
3 echo babbbbil 12223 | awk '{for(i=1;i<=NF;i++){if($i ~ "122"){print $i;i=NF+1}}}'
4
This piece of awk code will go through all the fields and look for pattern "122" and print them. The "i=NF+1" will work like "break;" in C which will make awk to stop printing after the first hit. Happy Awk'ing ;)
Controlling netgear ( D834G ) router from shell
You can perform the following operations from the shell
- Disconnect
- Connect
- Reconnect (Disconnect, then connect again)
- Show status
- reboot router
1 #!/bin/bash
2
3 router_ip=192.168.0.1
4 username="admin"
5 password="CHANGE-ME"
6
7 debug_url="http://$router_ip/setup.cgi?todo=debug"
8 status_url="http://$router_ip/setup.cgi?next_file=s_status.htm"
9 connection_url="http://$router_ip/setup.cgi?next_file=st_poe.htm"
10 disconnect_url="http://$router_ip/setup.cgi?todo=disconnect&next_file=st_poe.htm"
11 connect_url="http://$router_ip/setup.cgi?todo=connect&next_file=st_poe.htm"
12
13
14 RED='\e[1;31m'
15 CYAN='\e[1;36m'
16 NC='\e[0m' # No Color
17
18 tmp_file="/tmp/babil-router.info"
19 sleep_time=3
20
21
22 function clean_up()
23 {
24 rm -f $tmp_file
25 }
26
27 function reboot_router()
28 {
29 report=`wget -q --user $username --password $password $debug_url -O /dev/null`
30 echo "[+] $report"
31 sleep 2
32 (sleep 2; echo "reboot"; sleep 2) | telnet $router_ip
33 }
34
35
36 function ip()
37 {
38 #curl --basic --user $username:$password $status_url 2>/dev/null | sed -e :a -e 's/<[^>]*>//g;/<;/N;//ba' > $tmp_file
39 wget -q --user $username --password $password $status_url -O - | sed -e :a -e 's/<[^>]*>//g;/<;/N;//ba' > $tmp_file
40
41 c=1
42 while read line
43 do
44 #echo "$c $line"
45 if [[ $c == 71 ]];then
46 echo -e "[+] outbound ip : ${RED} $line ${NC}"
47
48 elif [[ $c == 83 ]];then
49 echo -e "[+] gateway ip : ${RED} $line ${NC}"
50
51 fi
52
53 c=$((c+1))
54
55 done < $tmp_file
56 clean_up
57 }
58
59
60 function stat()
61 {
62
63 ip
64
65 #curl --basic --user $username:$password $connection_url 2>/dev/null | sed -e :a -e 's/<[^>]*>//g;/<;/N;//ba' > $tmp_file
66 wget -q --user $username --password $password $connection_url -O - | sed -e :a -e 's/<[^>]*>//g;/<;/N;//ba' > $tmp_file
67
68 c=1
69 while read line
70 do
71 #echo "$c $line"
72 if [[ $c == 61 ]];then
73 echo -e "[+] duration : ${RED} $line ${NC}"
74
75 elif [[ $c == 65 ]];then
76 echo -e "[+] status : ${RED} $line ${NC}"
77
78 fi
79
80 c=$((c+1))
81
82 done < $tmp_file
83
84 clean_up
85
86 }
87
88
89 function connect()
90 {
91 echo -n "[+] connecting "
92 #curl --basic --user $username:$password $connect_url 2>/dev/null | sed -e :a -e 's/<[^>]*>//g;/<;/N;//ba' > $tmp_file
93 wget -q --user $username --password $password $connect_url -O - | sed -e :a -e 's/<[^>]*>//g;/<;/N;//ba' > $tmp_file
94 for ((i=0;i<$sleep_time;i++))
95 do
96 echo -n "."
97 sleep 1
98 done
99
100 echo
101 stat
102 }
103
104
105 function disconnect()
106 {
107 echo -n "[+] disconnecting "
108 #curl --basic --user $username:$password $disconnect_url 2>/dev/null | sed -e :a -e 's/<[^>]*>//g;/<;/N;//ba' > $tmp_file
109 wget -q --user $username --password $password $disconnect_url -O - | sed -e :a -e 's/<[^>]*>//g;/<;/N;//ba' > $tmp_file
110 for ((i=0;i<$sleep_time;i++))
111 do
112 echo -n "."
113 sleep 1
114 done
115
116 echo
117 stat
118 }
119
120 case "$1" in
121
122 connect)
123 echo
124 connect
125 echo
126 ;;
127
128 disconnect)
129 echo
130 disconnect
131 echo
132 ;;
133
134 stat)
135 echo
136 stat
137 echo
138 ;;
139 reboot)
140 echo
141 reboot_router
142 echo
143 ;;
144 reconnect)
145 echo
146 connect
147 echo
148 disconnect
149 echo
150 ;;
151 *)
152 echo
153 echo -e "[+] usage: `basename $0` { ${RED}connect | disconnect | reconnect | stat | reboot${NC} }"
154 echo
155 exit 1
156 ;;
157
158 esac
159
160
Saturday, November 22, 2008
Ubuntu (intrepid) - skype blocking audio device
After performing a very starnge (and stupid) migration from kubuntu-intrepid to edubuntu-intrepid, then to xbunbu-intrepid and lastly to original Ubuntu-intrepid, my skype sound was blocking all other audio softwares from using my sound card while in a skype-call (basically no software mixing).
I seem to have found two solutions for the problem after suffering and searching for almost a day:
solution-1:: making sure you have pulse-audio installed [1]
- backup previous configuration files
$ sudo rm -r ~/.pulse ~/.asound* /etc/asound.conf
- install pulse and adobe flash
solution-2:: create a dummy "skype" device for alsa [2]
- copy and paste the folling code in ~/.asoundrc and restart skype
pcm.skype {
type asym
playback.pcm "skypeout"
capture.pcm "skypein"
}
pcm.skypein {
# Convert from 8-bit unsigned mono (default format set by aoss when
# /dev/dsp is opened) to 16-bit signed stereo (expected by dsnoop)
#
# We can't just use a "plug" plugin because although the open will
# succeed, the buffer sizes will be wrong and we'll hear no sound at
# all.
type route
slave {
pcm "skypedsnoop"
format S16_LE
}
ttable {
0 {0 0.5}
1 {0 0.5}
}
}
pcm.skypeout {
# Just pass this on to the system dmix
type plug
slave {
pcm "dmix"
}
}
pcm.skypedsnoop {
type dsnoop
ipc_key 1133
slave {
# "Magic" buffer values to get skype audio to work
# If these are not set, opening /dev/dsp succeeds but no sound
# will be heard. According to the alsa developers this is due
# to skype abusing the OSS API.
pcm "hw:0,0"
period_size 256
periods 16
buffer_size 16384
}
bindings {
0 0
}
}
======================================================================
[1] http://ubuntuforums.org/showthread.php?t=789578&highlight=pulseaudio+perfect
[2] http://ubuntuforums.org/showthread.php?t=44753&page=15
Monday, October 27, 2008
Extract audio stream from a video file by "mencoder"
mplayer -vc null -vo null -ao pcm -benchmark test.avi
Labels
- amarok (2)
- android (4)
- antitaint (1)
- apache (1)
- apple trailers (1)
- apple tv (5)
- ati (2)
- avimerge (1)
- awk (8)
- bash (29)
- batch (1)
- bios (1)
- bittorrent (2)
- blah (1)
- bug (2)
- c (3)
- c++ (1)
- captcha (3)
- chromium (1)
- cityrail (3)
- clipboard (1)
- compiz (3)
- console (1)
- crystal hd (1)
- dccp (2)
- debian (18)
- dhcp (1)
- dictionary (2)
- dns (2)
- dokuwiki (1)
- dpkg (4)
- elitebook (1)
- epoch-time (1)
- epstopdf (1)
- evince (1)
- extract (1)
- fat32 (1)
- ffmpeg (2)
- fileserve (1)
- firefox (9)
- flurry (1)
- font (2)
- foxtel (1)
- funny (1)
- gdb (2)
- gmail (1)
- gnome (1)
- gnuplot (4)
- google-chrome (1)
- greasemonkey (1)
- grep (1)
- gtk (1)
- h264 (2)
- highlight (2)
- hotfile (1)
- hotkey (1)
- hotmail (1)
- hotspotter (1)
- hp (1)
- image-manipulation (3)
- initrd (1)
- iso (1)
- java (3)
- jelly bean (1)
- kernel (1)
- keyboard (1)
- klog (1)
- konqueror (1)
- ktorrent (1)
- laptop (1)
- latex (7)
- lcd (1)
- lightdm (1)
- linux (39)
- lubuntu (3)
- lxde (1)
- lyrics (4)
- lyx (2)
- mac (1)
- mangafox (1)
- miktex (2)
- mkv (2)
- monitor (1)
- mplayer (3)
- netgear (1)
- ns2 (2)
- onemanga (1)
- open-office (1)
- partition (1)
- pastebin (1)
- pdroid (1)
- pennytel (2)
- perl (1)
- php (1)
- pop (1)
- popup (1)
- premiumforfree (1)
- printk (2)
- programming (3)
- prothom-alo (2)
- python (3)
- rapidshare (1)
- real-audio (1)
- reverse-engineering (3)
- screensaver (1)
- sed (6)
- skype (2)
- sms (1)
- ssh (1)
- strace (1)
- swap (1)
- synergy (1)
- taint (1)
- taintdroid (1)
- tcl (1)
- tcpdump (1)
- teleport (1)
- theme (1)
- tshark (3)
- tvshark (1)
- ubuntu (35)
- uuid (1)
- vim (5)
- virtual-box (2)
- vnc (1)
- webmail (2)
- windows (7)
- windows8 (2)
- wine (4)
- wireshark (1)
- word-list (1)
- x11 (3)
- yahoo (1)

