Command in Ubuntu to create the win7 virtual machine using the raw disk Windows 7 partition that comes with the Dell computer.
This is tested on Virtual Box 4.0.4
Make sure you run everything as root
Make sure you use "IDE controller" type ICH6, otherwise the win7 will blue screen (BSOD)
This is based on the following blogs:
http://www.rajatarya.com/website/taming-windows-virtualbox-vm
http://www.researchut.com/site/virtualbox-native-partition
First install Virtualbox. I found it easier to install it using the "all platform" exectuable. Make sure you also download and install the Oracle Extension Package, which is installed using this command:
VBoxManage extpack install Extention_file_name
Then do the following commands: make sure you are root, and you are at "/root".
----------------
VBoxManage createvm --name win7 --ostype Windows7_64 --register
VBoxManage modifyvm "win7" --memory 1024 --acpi on --boot1 disk --nic1 nat
VBoxManage storagectl "win7" --name "IDE Controller" --add ide --controller ICH6
VBoxManage internalcommands createrawvmdk -filename /root/win7.vmdk -rawdisk /dev/sda -partitions 1,2,3 -mbr /root/vm.mbr -relative
VBoxManage storageattach win7 --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium /root/win7.vmdk
------ Other useful commands------------
vboxmanage unregistervm win7 --delete
VBoxManage storageattach win7 --storagectl "IDE Controller" --port 0 --device 1 --type dvddrive --medium "/root/Windows 7 64-bit Repair Disc.iso"
VBoxManage storageattach win7 --storagectl "IDE Controller" --port 0 --device 1 --type dvddrive --medium /opt/VirtualBox/additions/VBoxGuestAdditions.iso
vboxmanage controlvm win7 reset
----If you still cannot boot your Windows 7, try to use the Windows 7 Rescue image to fix it. Use the above "vboxmanage" command to attach the repair disk ISO file and hit F12 when vbox boots to boot from CD, let it fixes it and then boot to regular Win7
May 20, 2011
May 19, 2011
May 18, 2011
Headless Virtualbox on Ubuntu 10.04 LTS
Updated Scripts (06/07/2012):
VBoxManage createvm -name centos6 --ostype RedHat -register
VBoxManage modifyvm centos6 --memory 1024 --pae on --acpi on --boot1 dvd --nic1 nat --natpf1 "guestssh,tcp,,2222,,22"
To enable VRDE:
VBoxManage modifyvm centos6 --vrde on --vrdeport 3392
To add the second interface as bridged interface:
Original Post:
http://tuxnetworks.blogspot.com/2010/05/howto-virtualbox-31-headless-on-lucid.html
That's it, Virtualbox should be installed and ready to go.
Now we can move on to creating a virtual machine
Create a machine named "io"
Configure it with a nic bridged to eth0, 256Mb RAM, enable acpi and set to boot from DVD
Create a virtual IDE controller
Create a virtual HDD
Attach the virtual HDD
Create and attach a virtual DVD drive to the controller and insert the DVD image
The default vrdp port for machines is 3389, however, if you intend to run more than one guest then each one will need to listen on a different port. I use the 3xxx range with the xxx being the last octet of the machines IP address. For example, 192.168.0.1 would be 3001.
And thats it, your machine has been created. Time to start it up and give it a test drive!
Using the virtual machine
Start the machine
On a GUI workstation, establish a remote desktop connection to the machine. In my case, the host server is called "jupiter" so I type;
After you have installed the OS, you need to tell the machine to boot from the hdd.
You can also deregister the dvd image if you don't intend to use it again.
To Stop VM/Hibernate/Save Sate:
vboxmanage controlvm centos6 savestate
Here are some other useful commands;
VBoxManage createvm -name centos6 --ostype RedHat -register
VBoxManage modifyvm centos6 --memory 1024 --pae on --acpi on --boot1 dvd --nic1 nat --natpf1 "guestssh,tcp,,2222,,22"
VBoxManage modifyvm centos6 --natpf1 "www,tcp,,1888,,80"
VBoxManage storagectl centos6 --name IDE0 --add ide --controller ICH6
VBoxManage createhd -filename ~/centos6/sda.vdi -size 20000
VBoxManage storageattach centos6 --storagectl IDE0 --port 0 --device 0 --type hdd --medium ~/centos6/sda.vdi
VBoxManage storageattach centos6 --storagectl IDE0 --port 1 --device 0 --type dvddrive --medium ~/bigfiles/CentOS-6.2-i386-minimal.iso
To enable VRDE:
VBoxManage modifyvm centos6 --vrde on --vrdeport 3392
After installation is finished, boot hdd:
VBoxManage modifyvm centos6 --boot1 disk
To add hostonly interface:
# sudo tunctl -u $USER # add tap0 device
# sudo ifconfig tap0 192.168.100.1 netmask 255.255.255.0
VBoxManage modifyvm centos6 --nic2 hostonly --hostonlyadapter2 tap0
To add the second interface as bridged interface:
VBoxManage modifyvm centos6 --nic2 bridged --bridgeadapter2 eth0
Original Post:
http://tuxnetworks.blogspot.com/2010/05/howto-virtualbox-31-headless-on-lucid.html
That's it, Virtualbox should be installed and ready to go.
Now we can move on to creating a virtual machine
Create a machine named "io"
VBoxManage createvm -name io --ostype Ubuntu -register
Configure it with a nic bridged to eth0, 256Mb RAM, enable acpi and set to boot from DVD
VBoxManage modifyvm io --memory 256 --pae on --acpi on --boot1 dvd --nic1 bridged --bridgeadapter1 eth0
Create a virtual IDE controller
VBoxManage storagectl io --name IDE0 --add ide
Create a virtual HDD
VBoxManage createvdi -filename ~/.VirtualBox/Machines/io/sda.vdi -size 48000 -register
Attach the virtual HDD
VBoxManage storageattach io --storagectl IDE0 --port 0 --device 0 --type hdd --medium ~/.VirtualBox/Machines/io/sda.vdi
Create and attach a virtual DVD drive to the controller and insert the DVD image
VBoxManage storageattach io --storagectl IDE0 --port 1 --device 0 --type dvddrive --medium /store/archive/ISO/ubuntu-10.04-server-i386.iso
The default vrdp port for machines is 3389, however, if you intend to run more than one guest then each one will need to listen on a different port. I use the 3xxx range with the xxx being the last octet of the machines IP address. For example, 192.168.0.1 would be 3001.
VBoxManage modifyvm io --vrdpport 3001
And thats it, your machine has been created. Time to start it up and give it a test drive!
Using the virtual machine
Start the machine
nohup VBoxHeadless -startvm io &
On a GUI workstation, establish a remote desktop connection to the machine. In my case, the host server is called "jupiter" so I type;
rdesktop -a 8 jupiter:3001
After you have installed the OS, you need to tell the machine to boot from the hdd.
VBoxManage modifyvm io --boot1 disk
You can also deregister the dvd image if you don't intend to use it again.
VBoxManage unregisterimage dvd /store/archive/ISO/ubuntu-10.04-server-i386.iso
To Stop VM/Hibernate/Save Sate:
vboxmanage controlvm centos6 savestate
To Power Off VM:
vboxmanage controlvm centos6 poweroff
Here are some other useful commands;
VBoxManage showvminfo io VBoxManage list hdds VBoxManage list runningvms VBoxManage controlvm io poweroff VBoxManage unregistervm io --delete VBoxManage controlvm io savestate VBoxManage closemedium disk UUID VBoxManage modifyhd UUID --type immutable
May 17, 2011
Linux Command Line FTP/HTTP segemented download accelartor software
aria2c
axel
lftp (use the "pget" command of lftp)
ari2c and axel supports FTP, HTTP and HTTPS, while lftp supports more protocols such as FTPS, SFTP, etc.
May 16, 2011
/etc/hosts not working?
If you have a Linux machine and your /etc/hosts is not working, make sure you have a file called
/etc/nsswitch.conf
with the following content: passwd: files group: files hosts: files dns networks: files dns services: files protocols: files netmasks: files
May 13, 2011
Windows CE 5.0 QFE download
Microsoft has moved on to Windows CE 7 (Compact 7) and revamped their download site so that all the windows CE 5.0 downloads cannot be located anymore.
To patch your platform builder 5.0 to the latest, download the "rollup" files from here:
http://www.microsoft.com/windowsembedded/en-us/downloads/download-windows-embedded-ce-5.aspx
Once you installed any QFE, you will have a application called CEQFECHECK.exe under C:\WINDOWS\system32\ceqfecheck. This application checks which QFE you have installed and did not install. Check it out.
To patch your platform builder 5.0 to the latest, download the "rollup" files from here:
http://www.microsoft.com/windowsembedded/en-us/downloads/download-windows-embedded-ce-5.aspx
Once you installed any QFE, you will have a application called CEQFECHECK.exe under C:\WINDOWS\system32\ceqfecheck. This application checks which QFE you have installed and did not install. Check it out.
May 5, 2011
Linux Network Interface statistics
http://stackoverflow.com/questions/596590/how-can-i-get-the-current-network-interface-throughput-statistics-on-linux-unix
Tools include:
1. bwm-ng
2. iftop
3. iptraf
4. sar
5. dstat
Tools include:
1. bwm-ng
2. iftop
3. iptraf
4. sar
5. dstat
April 18, 2011
jQuery TableSorter "o is undefined" problem
If you use jQuery TableSorter and see the "o is undefined" problem, it is the probably the case that you are using "<td>" inside the <thead> section instead of <th>. Use <th> and you will be good.
March 17, 2011
sqlite pdo write lock problem solved
When using PHP and PDO to access an sqlite dababase, and when you do a "select *" using the $handle->query($sqlcmd), you must use "foreach" to read all the select results before you can issue the next "query" or "exec" call. Otherwise, the database will be locked.
March 4, 2011
Win32 applications GUI vs Console
This web page explains well the difference between a WIN32 GUI app vs. Console app.
March 3, 2011
php header redirect IE issue
In web development, a HTTP POST is often processed on the server ending with a header("Location:page.php") call, so that user can refresh their page without re-posting. This usually works well.
The only issue is IE. After posting or file upload, using the PHP header() call won't work with IE, although it works with Firefox. You will have to use the HTML direct instead.
The only issue is IE. After posting or file upload, using the PHP header() call won't work with IE, although it works with Firefox. You will have to use the HTML direct instead.
February 9, 2011
Windows CE ssh server and client
Windows CE development is not as fun as Linux because of the lack of open source tools. However, once I am able to make ssh server and client running on it, it becomes better. Here is how to get ssh server and client running on windows CE 5 (ARM based):
1. Download CESSH at http://www.codeplex.com/wikipage?projectname=CESSH
Download sshd_config at http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=CESSH&DownloadId=3561
Download file http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=CESSH&DownloadId=3562
2. copy the files to your windows CE device, suppose "\ssh"
3. mkdir "\Hard Disk"
4. copy sshd_config "\Hard Disk"
5. mkdir "\NandFlash"
6. mkdir "\NandFlash\ssh"
7. copy ssh_host_dsa_key to "\NandFlash\ssh"
8. run "adduser.exe root rootpass" to add the user "root" with password "rootpass"
9. copy SocketToFile.DLL to \windows
10. run "sshd.exe"
To test it, get pocketputty
(http://www.pocketputty.net/download.html)
If make this work over ActiveSync, use the remote port tunnel in putty.
Another great tool to have is netcat for CE: http://www.dr-bischoff.de/wince/Andreas_WINCE_stuff.html#netcat
Hope this helps.
1. Download CESSH at http://www.codeplex.com/wikipage?projectname=CESSH
Download sshd_config at http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=CESSH&DownloadId=3561
Download file http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=CESSH&DownloadId=3562
2. copy the files to your windows CE device, suppose "\ssh"
3. mkdir "\Hard Disk"
4. copy sshd_config "\Hard Disk"
5. mkdir "\NandFlash"
6. mkdir "\NandFlash\ssh"
7. copy ssh_host_dsa_key to "\NandFlash\ssh"
8. run "adduser.exe root rootpass" to add the user "root" with password "rootpass"
9. copy SocketToFile.DLL to \windows
10. run "sshd.exe"
To test it, get pocketputty
(http://www.pocketputty.net/download.html)
If make this work over ActiveSync, use the remote port tunnel in putty.
Another great tool to have is netcat for CE: http://www.dr-bischoff.de/wince/Andreas_WINCE_stuff.html#netcat
Hope this helps.
February 4, 2011
Slick board and XML/SWF charts
SlickBoard and XML/SWF charts seem like very great products. Let me know if you have used it.
And also the google visualization tools which give you access to google finance like charts (http://code.google.com/apis/visualization/documentation/gallery/annotatedtimeline.html)
And also the google visualization tools which give you access to google finance like charts (http://code.google.com/apis/visualization/documentation/gallery/annotatedtimeline.html)
January 28, 2011
January 27, 2011
git, cgit and mini_httpd
git allows very easy local installation. We need a easy way to view the local git repository. mini_httpd is a great local web server to use, and git web app can either be "gitweb" or "cgit".
I tried "gitweb" but couldn't get it to see my projects. But I got "cgit" to work well. Here is how:
1. download and compile cgit. very simple, just follow the README file.
2. change cgit Makefile, "CGIT_CONFIG = /yourpath/cgitrc", then "touch cgit.c" and "make" again. We do this because by default cgitrc is located at /etc/ and we want it local.
3. Create your cgitrc file from the example file. I use something like this:
I tried "gitweb" but couldn't get it to see my projects. But I got "cgit" to work well. Here is how:
1. download and compile cgit. very simple, just follow the README file.
2. change cgit Makefile, "CGIT_CONFIG = /yourpath/cgitrc", then "touch cgit.c" and "make" again. We do this because by default cgitrc is located at /etc/ and we want it local.
3. Create your cgitrc file from the example file. I use something like this:
cache-size=0 css=/cgit.css enable-index-links=1 enable-log-filecount=1 enable-log-linecount=1 max-stats=quarter root-title=My git repository root-desc=Tracking my project development root-readme=about.html snapshots=tar.gz mimetype.git=image/git mimetype.html=text/html mimetype.jpg=image/jpeg mimetype.jpeg=image/jpeg mimetype.pdf=application/pdf mimetype.png=image/png mimetype.svg=image/svg+xml repo.url=linux repo.path=/opt/gittest/.git repo.desc=My project repo.owner=me@me.com repo.readme=info/web/about.html repo.snapshots=tar.gz repo.enable-log-linecount=0 repo.max-stats=month4. start minihttpd and your are in business. :-)
January 26, 2011
Vim non greedy regular expression search
* (0 or more) greedy matching
\+ (1 or more) greedy matching
\{-} (0 or more) non-greedy matching
\{-n,} (at least n) non-greedy matchinghttp://blog.vinceliu.com/2008/02/non-greedy-regular-expression-matching.html
CSS Positioning explained
http://www.barelyfitz.com/screencast/html-training/css/positioning/
Simple truth:
1. Use positon:relative in the outer box and then positoin:absolute in the inner box. This is very effective.
2. When using position:absolute with background image, make sure you explicitly specify "width" and "height", otherwise it won't work.
Simple truth:
1. Use positon:relative in the outer box and then positoin:absolute in the inner box. This is very effective.
2. When using position:absolute with background image, make sure you explicitly specify "width" and "height", otherwise it won't work.
CSS and box shadow (blurred shadow)
All major browsers except IE (IE9 may support it) supports the CSS3 box shadow. So you need the javascript to do some tricks for IE. Here is the link. http://www.hintzmann.dk/testcenter/js/jquery/boxshadow/
January 24, 2011
Use Linux to control power outlet via USB
Much of information on this page is based the web page at here
1. buy EcoStrip , and Linksys USB2HUB4 USB 2.0 hub. This hub supports power control. Internally it uses NEC chipset.
2. Download hub-ctrl.c, OR download it at this site
3. Use lsusb utilities with -v option, you can inspect 'Hub Descriptor', such like:
4.compile hub-ctrl.c with -lusb (you need to install libusb-dev if you don't have it)
5. run "sudo ./hub-ctrl" to list the possible hub that supports power control
1. buy EcoStrip , and Linksys USB2HUB4 USB 2.0 hub. This hub supports power control. Internally it uses NEC chipset.
2. Download hub-ctrl.c, OR download it at this site
3. Use lsusb utilities with -v option, you can inspect 'Hub Descriptor', such like:
Hub Descriptor:
[...]
wHubCharacteristic 0x0089
Per-port power switching
Per-port overcurrent protection
Port indicators
[...]4.compile hub-ctrl.c with -lusb (you need to install libusb-dev if you don't have it)
5. run "sudo ./hub-ctrl" to list the possible hub that supports power control
Bus 002 Device 003: ID 0409:0058 NEC Corp. HighSpeed Hub Bus 002 Device 002: ID 8087:0020 Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 002: ID 8087:0020 Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
6.From above, you can see that my Linksys hub is located at Bus 2 Device 3. So I use the following command to turn the ecoStrip (which is plugged into the Linksys Hub port 1) power off:
sudo ./hub-ctrl -b 2 -d 3 -P 1
And the following command to turn it on
sudo ./hub-ctrl -b 2 -d 3 -P 1 -p 1
January 21, 2011
transfer or populate sqlite table to another table
INSERT INTO TABLE2 (COL1, COL2, COL3) SELECT COL1, COL4, COL7 FROM TABLE1
January 19, 2011
Use PHP to receive email
I use "sendmail". Other MTA should be similar.
1. Supposed you want php to receive emails destined to "support@example.com". Go to /etc/aliases and add a line:
support: "|/usr/local/bin/getemail.php"
2. restart sendmail
3. go to /etc/smrsh, and create two symbolic link files:
ln -s /usr/bin/php php
ln -s /usr/local/bin/getemail.php getemail.php
These symbolic links basically tells sendmail you know these programs are safe for it to run
4. create your php script. A simple php script looks like this. Of course you should add your logic to it.
1. Supposed you want php to receive emails destined to "support@example.com". Go to /etc/aliases and add a line:
support: "|/usr/local/bin/getemail.php"
2. restart sendmail
3. go to /etc/smrsh, and create two symbolic link files:
ln -s /usr/bin/php php
ln -s /usr/local/bin/getemail.php getemail.php
These symbolic links basically tells sendmail you know these programs are safe for it to run
4. create your php script. A simple php script looks like this. Of course you should add your logic to it.
$fd = fopen("php://stdin", "r");
$email = "";
while (!feof($fd)) {
$email .= fread($fd, 1024);
}
fclose($fd);
file_put_contents("/tmp/email.txt",$email);
die();
January 18, 2011
See which file is preventing you from mount read-only
In embedded systems, you can make your entire root file system read only (therefore preventing flash corruption) by doing:
mount -o remount,ro /
lsof +D / | awk $4~/w$/{print}
This commands list all open files recursively then uses an one-line awk script to find the lines that have files open for write.
lsof is a really good friend. :-)
January 11, 2011
PHP PDF import and modification
There is a php library that allows importing a page from an existing PDF file, and then write data/graph on top of it. This essentially allows one to modify a pdf file.
The library is called FPDI (http://www.setasign.de/products/pdf-php-solutions/fpdi/about/). It uses the basic PDF library FPDF, or TCPDF (which is a fork of FPDF).
Seems useful. haven't tried it yet.
More: tried it yesterday and it works beautifully!! Use GSview32 to find the exact x/y of the place where you want to insert text/graph.
Another gem found.
The library is called FPDI (http://www.setasign.de/products/pdf-php-solutions/fpdi/about/). It uses the basic PDF library FPDF, or TCPDF (which is a fork of FPDF).
Seems useful. haven't tried it yet.
More: tried it yesterday and it works beautifully!! Use GSview32 to find the exact x/y of the place where you want to insert text/graph.
Another gem found.
January 10, 2011
https, TLS, SSL and multiple hosts
http://en.wikipedia.org/wiki/Server_Name_Indication
Unfortunately Windows XP with IE does not support this.
Unfortunately Windows XP with IE does not support this.
December 28, 2010
Use sqlite3 with codeigniter
Codeigniter is a small, fast, and well-documented web framework. However, currently (as of version 1.7.3), only sqlite2 is supported. I made codeigniter 1.7.3 work with sqlite3, including the scaffolding feature, which I really like.
Here is how to make codeigniter 1.7.3 work with sqlite3:
1. Download the php-based sqlite3 PDO driver for codeigniter. This driver is based on the driver in the codeigniter wiki, but fixed up so it works with v1.7.3 and with scaffolding.
Download the sqlite3 PDO driver (based on the wiki driver 0.2)
2. Edit system/database/DB_driver.php, around line 831, add the 4 lines below starting with '+'.
3. Create directory /pdo in /database/drivers and copy to this directory
driver *.php files
4. Create SQLite3 database file, and put it to any directory.
My database file is [APPPATH]/db/base.db
5. In application database config [APPPATH]/config/database.php set next settings:
Enjoy.
Here is how to make codeigniter 1.7.3 work with sqlite3:
1. Download the php-based sqlite3 PDO driver for codeigniter. This driver is based on the driver in the codeigniter wiki, but fixed up so it works with v1.7.3 and with scaffolding.
Download the sqlite3 PDO driver (based on the wiki driver 0.2)
2. Edit system/database/DB_driver.php, around line 831, add the 4 lines below starting with '+'.
foreach($query->result_array() as $row)
{
if (isset($row['COLUMN_NAME']))
{
$retval[] = $row['COLUMN_NAME'];
}
+ else if ($this->platform()=="pdo")
+ {
+ $retval[] = next($row);
+ }
else
{
$retval[] = current($row);
}
}
3. Create directory /pdo in /database/drivers and copy to this directory
driver *.php files
4. Create SQLite3 database file, and put it to any directory.
My database file is [APPPATH]/db/base.db
5. In application database config [APPPATH]/config/database.php set next settings:
$db['default']['hostname'] = ''; $db['default']['username'] = '';$db['default']['password'] = '';$db['default']['database'] = 'sqlite:'.APPPATH.'db/base.db';$db['default']['dbdriver'] = 'pdo'; Enjoy.
December 27, 2010
vimdiff ignoring white space
I had been searching for a way to ignore white spaces while using vimdiff. Unfortunately, vimdiff -h yields the generic Vim help. I finally found that including the following line in vimrc solves the problem.
set diffopt+=iwhiteFrom the command line:
vimdiff -c 'set diffopt+=iwhite' ...
December 22, 2010
codeignitor removes index.php
Ok, try
in config.php set
With this htaccess index.php-hiding works for me with PHP4 and PHP5 running PHP as a CGI
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L] <-- do not forget the ? after index.php!
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
ErrorDocument 404 /index.php</IfModule> $config['index_page'] = "";$config['uri_protocol'] = "AUTO"; Corss Compile tcpdump for linux/mips
1. download libpcap (I use version 1.1.1 at the time of post) and tcpdump (v4.1.1 as of time of post)
2. unzip both directory under the same directory, such as download/libpcap-1.1.1 and download/tcpdump-4.1.1
Build libpcap:
3. cd libpcap-1.1.1 ;
4. vi configure; search for "linux version", and remove the entire section of "case" under "linux)" until "do we have the wireless extensions". This is so that ./configure does not try to detect linux (and fail). Our linux is fine.
5. CC=/YOUR-CROSS-COMPILER-PATH/mips-openwrt-linux-gcc ./configure --host=mips-linux --with-pcap=linux
6. make. after make is successful, you'll have a libpcap.a
Build tcpdump:
7. cd ../tcpdump-4.1.1
8 .vi configure; earch for "linux version", and remove the entire section of "case" under "linux*)" until ";; \n *)".
9. CC=/YOUR-CROSS-COMPILER-PATH/mips-openwrt-linux-gcc ./configure --host=mips-linux --with-pcap=linux
10. vi Makefile; search for /usr/include and remove them; the Makefile by mistake include including files in the host system. Remove them.
11. make. you can strip the final tcpdump if you like. all done.
2. unzip both directory under the same directory, such as download/libpcap-1.1.1 and download/tcpdump-4.1.1
Build libpcap:
3. cd libpcap-1.1.1 ;
4. vi configure; search for "linux version", and remove the entire section of "case" under "linux)" until "do we have the wireless extensions". This is so that ./configure does not try to detect linux (and fail). Our linux is fine.
5. CC=/YOUR-CROSS-COMPILER-PATH/mips-openwrt-linux-gcc ./configure --host=mips-linux --with-pcap=linux
6. make. after make is successful, you'll have a libpcap.a
Build tcpdump:
7. cd ../tcpdump-4.1.1
8 .vi configure; earch for "linux version", and remove the entire section of "case" under "linux*)" until ";; \n *)".
9. CC=/YOUR-CROSS-COMPILER-PATH/mips-openwrt-linux-gcc ./configure --host=mips-linux --with-pcap=linux
10. vi Makefile; search for /usr/include and remove them; the Makefile by mistake include including files in the host system. Remove them.
11. make. you can strip the final tcpdump if you like. all done.
December 17, 2010
How to cross compile tinyproxy for mips
tinyproxy version: 1.8.2
1. Change the configure file to comment the section containing "Check for asciidoc" until all the way to "ac_config_files=" (not including). Also Remove the lines that test "HAVE_A2X_TRUE".
2. CC=/home/tzhang/filter/trunk/toolchain_bin/mips-openwrt-linux-gcc ./configure --host=mips-linux --enable-filter --disable-upstream --disable-reverse --enable-transparent --disable-regexcheck
3. modify config.h: search for "rpl_", and comment the two lines that contains rpl_malloc and rpl_remalloc. Use /* */ syntax to comment out.
4. vi src/Makefile, search for "LDFLAGS", and append " -s" to it (to strip the final binary)
5. Chanage Makefile to only build src. Find SUBDIRS , comment out all other directories other than "src".
6. Make. find the binary at src/tinyproxy.
1. Change the configure file to comment the section containing "Check for asciidoc" until all the way to "ac_config_files=" (not including). Also Remove the lines that test "HAVE_A2X_TRUE".
2. CC=/home/tzhang/filter/trunk/toolchain_bin/mips-openwrt-linux-gcc ./configure --host=mips-linux --enable-filter --disable-upstream --disable-reverse --enable-transparent --disable-regexcheck
3. modify config.h: search for "rpl_", and comment the two lines that contains rpl_malloc and rpl_remalloc. Use /* */ syntax to comment out.
4. vi src/Makefile, search for "LDFLAGS", and append " -s" to it (to strip the final binary)
5. Chanage Makefile to only build src. Find SUBDIRS , comment out all other directories other than "src".
6. Make. find the binary at src/tinyproxy.
December 16, 2010
bfilter
A web proxy filter that blocks ads, achieves effects like Firfox AdBlock Plus.
http://Bfilter.sourceforge.net
http://Bfilter.sourceforge.net
December 15, 2010
vim global command
http://www.networkcomputing.com/unixworld/tutorial/009/009.part3.html
syntax: g/stuff-to-search/[range]EX command
example:
syntax: g/stuff-to-search/[range]EX command
example:
global /^/ + delete
:g/blah/d , this deletes all lines containging 'blah'
:g/blah/ ,+ delete , this deletes all lines and next lines that containing 'blah'
See more at http://vimdoc.sourceforge.net/htmldoc/cmdline.html#Command-line
December 14, 2010
December 11, 2010
iptables SO_ORIGINAL_DST
this option in socket call can let you retrieve the original IP and port number of a redirected TCP session. Brilliant.
December 9, 2010
Git Get Started
Getting Started
Let's say you have a development project in the directory devproject. Let's start using Git to manage this project.
First off install Git. In Debian and Ubuntu we just need to do "aptitude install git"
At this point you have all the benefits of a local version control system but no one can see your work. To make it available to other people we'll need to install a remote repository on your server. At home, I only allow people to access my code through SSH so that's the method I am going to talk about here.
Your remote Git server is now configured so let's set up our local repository to talk to the remote repository
We can now push our changes to that repository:
Let's say you have a development project in the directory devproject. Let's start using Git to manage this project.
First off install Git. In Debian and Ubuntu we just need to do "aptitude install git"
cd devproject git init git add . git commit -m "My first commit"
ssh alex mkdir -p /var/git/devproject.git cd /var/git/devproject.git git --bare init exit
cd devproject git remote add origin ssh://alex/var/git/devproject.git
git push origin master
git clone: clone from a remote a new local repository
git fetch: update the local "remote" directory
git pull: = git fetch + git merge
December 8, 2010
Compile Openssl for Linux MIPS
1. Grab openssl source 1.0.c
2. Grab the Linux-MIPS patch at http://svn.cross-lfs.org/svn/repos/patches/openssl/openssl-0.9.8k-mips_support-1.patch
3. apply the patch: the patch basically just add a few lines to the Configure file. you can do that manually if you want.
4. CC=YOUR-MIPS-CC ./configure linux-mips (add "shared" if you want to build shared library)
5. make
2. Grab the Linux-MIPS patch at http://svn.cross-lfs.org/svn/repos/patches/openssl/openssl-0.9.8k-mips_support-1.patch
3. apply the patch: the patch basically just add a few lines to the Configure file. you can do that manually if you want.
4. CC=YOUR-MIPS-CC ./configure linux-mips (add "shared" if you want to build shared library)
5. make
December 7, 2010
Increase VNC Speed (tightvnc)
- If you select the "Low-bandwidth connection" option under "Connection profile" a lot of the default options will be changed. You will notice a drastic increase in performance from that allowance.
- If you want to tweak the connection further, click the "Options" button to see what is under the hood. Choose the "Tight" encoding option to use TightVNC's compression. Select "Use 8-bit color" to reduce the number of colors and therefore increase speed. Below that, slide the compression bar down to its fastest point to make major changes on performance. Keep in mind that this will also affect the image quality.
December 6, 2010
rSync for Windows
1. Download the zipfile for DelteCopy (Without Installer)
2. Unzip it. It includes rsync.exe for Windows
3. copy deltecd.conf to rsyncd.conf
4. run it as a daemon: rsync --daemon --no-detach --config=\PATH\rsyncd.conf
5. if that works, it will open a port on 873 (make sure you firewall is off).
6. to make it permanent, you can use "srvany" to install it as a service.
More detailed instructions can be found at HERE.
2. Unzip it. It includes rsync.exe for Windows
3. copy deltecd.conf to rsyncd.conf
4. run it as a daemon: rsync --daemon --no-detach --config=\PATH\rsyncd.conf
5. if that works, it will open a port on 873 (make sure you firewall is off).
6. to make it permanent, you can use "srvany" to install it as a service.
More detailed instructions can be found at HERE.
Edit Motion Jpeg on Windows
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Background:
Digital Still Cameras for the last couple of years have been able to record video. The cameras put the video (and usually PCM aka RAW audio) in either Quicktime (MOV) or AVI containers.
The video codec is usually Motion JPEG (FourCC:MJPG) because the chip in the camera usually makes JPG and making Motion JPEG is a trivial extension since MJPEG is close to sequential JPEGs.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Technical hurdle on the PC:
To be able to play video or audio you need to have a de-compressor to understand the container (eg MOV, AVI) AND a de-compressor for each stream in the container.
Container examples: "MOV" –QuickTime Movie, "AVI" – Windows’ implementation of the “RIFF” format.
video examples: "M2V" -mpeg2 video, "MJPG" - Motion JPEG.
audio example: "PCM" - raw audio, "AC3" - Dolby Digital audio.
The algorithm is either built into the tool (eg MOV decode in QuickTime, Adobe & free tools like MPlayer etc) OR it has to be present as installed component on the PC.
On Windows there are TWO sorts of CODECs. The original "Video For Windows" (VfW) and DirectShow.
Editing tools (in general) ONLY work with VfW codecs.
Windows XP, Vista and Win7 all ship with DirectShow MJPEG codecs, but not VfW ….so easy to watch but you can’t EDIT.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
The problem:
So you have these MOV[ MJPEG + PCM ] or AVI[ MJPEG + PCM ] files and want to edit them to do something as simple as put them on a DVD for mom to see the new baby.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
The solution:
You can buy a VfW Motion JPEG decoder (eg http://www.morgan-multimedia.com/M-JPEG2000/index.htm )
OR you can get it in freeware.
FFDshow ( http://sourceforge.net/projects/ffdshow/ ) uses the libavcodec library developed in the FFmpeg Movie Player ( http://ffmpeg.org/ ) open-source effort. The libavcodec library has TONS of codecs. It is better known for its MPEG4, Xvid, DivX but it also has a lot of others. One of those “others” is MJPG.
The FFDshow project takes that decode (and in some cases encode too) capability and presents them as VfW (as well as DirectShow) codecs!
Viola, you now have the ability to understand MJPEG in video editing tools. (and tons of other codecs if you enable them).
The only thing you need to do after installation is go to the Start Menu’s “FFDShow VFW Configuration” and under the “Decoder” tab’s “Codecs” (at the top). Then on the right side scroll down to MJPEG and change it from “disabled” to “libavcodec”.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
An Aside:
This will become more and more important in the years to come because motion films are shot and delivered to digital cinemas as “2k”, “4k” or “8k” ( http://en.wikipedia.org/wiki/Digital_cinema ) in MOTION JPEG2000 ( http://en.wikipedia.org/wiki/JPEG_2000#Motion_JPEG_2000 ) . It’s only so long before INDIE film makers and then pro-sumers want to edit in these resolutions.
‘thanks for reading.
[EDIT - LeChineur had problems with this solution. Instead of you having to read this entire thread I'm putting an edit here to summarize the problem]
In the end it came down to this. LeChineur's FFDshow install didn't work. In summary:
Background:
Digital Still Cameras for the last couple of years have been able to record video. The cameras put the video (and usually PCM aka RAW audio) in either Quicktime (MOV) or AVI containers.
The video codec is usually Motion JPEG (FourCC:MJPG) because the chip in the camera usually makes JPG and making Motion JPEG is a trivial extension since MJPEG is close to sequential JPEGs.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Technical hurdle on the PC:
To be able to play video or audio you need to have a de-compressor to understand the container (eg MOV, AVI) AND a de-compressor for each stream in the container.
Container examples: "MOV" –QuickTime Movie, "AVI" – Windows’ implementation of the “RIFF” format.
video examples: "M2V" -mpeg2 video, "MJPG" - Motion JPEG.
audio example: "PCM" - raw audio, "AC3" - Dolby Digital audio.
The algorithm is either built into the tool (eg MOV decode in QuickTime, Adobe & free tools like MPlayer etc) OR it has to be present as installed component on the PC.
On Windows there are TWO sorts of CODECs. The original "Video For Windows" (VfW) and DirectShow.
Editing tools (in general) ONLY work with VfW codecs.
Windows XP, Vista and Win7 all ship with DirectShow MJPEG codecs, but not VfW ….so easy to watch but you can’t EDIT.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
The problem:
So you have these MOV[ MJPEG + PCM ] or AVI[ MJPEG + PCM ] files and want to edit them to do something as simple as put them on a DVD for mom to see the new baby.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
The solution:
You can buy a VfW Motion JPEG decoder (eg http://www.morgan-multimedia.com/M-JPEG2000/index.htm )
OR you can get it in freeware.
FFDshow ( http://sourceforge.net/projects/ffdshow/ ) uses the libavcodec library developed in the FFmpeg Movie Player ( http://ffmpeg.org/ ) open-source effort. The libavcodec library has TONS of codecs. It is better known for its MPEG4, Xvid, DivX but it also has a lot of others. One of those “others” is MJPG.
The FFDshow project takes that decode (and in some cases encode too) capability and presents them as VfW (as well as DirectShow) codecs!
Viola, you now have the ability to understand MJPEG in video editing tools. (and tons of other codecs if you enable them).
The only thing you need to do after installation is go to the Start Menu’s “FFDShow VFW Configuration” and under the “Decoder” tab’s “Codecs” (at the top). Then on the right side scroll down to MJPEG and change it from “disabled” to “libavcodec”.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
An Aside:
This will become more and more important in the years to come because motion films are shot and delivered to digital cinemas as “2k”, “4k” or “8k” ( http://en.wikipedia.org/wiki/Digital_cinema ) in MOTION JPEG2000 ( http://en.wikipedia.org/wiki/JPEG_2000#Motion_JPEG_2000 ) . It’s only so long before INDIE film makers and then pro-sumers want to edit in these resolutions.
‘thanks for reading.
[EDIT - LeChineur had problems with this solution. Instead of you having to read this entire thread I'm putting an edit here to summarize the problem]
In the end it came down to this. LeChineur's FFDshow install didn't work. In summary:
Originally Posted by LeChineur
This got me thinking. So I checked and I indeed did not have the ff_vfw.dll on my system. So I uninstalled the version 3.054 of FFDShow (dated 08/04/2009) which was installed on my system, downloaded and installed version 3.052 (dated 08/03/2009) and voila, I then had the ff_vfw.dll.
That solved the problem. PP now plays the video clip fine, as well as all the other "AVI" (MJPEG) clips from my Canon camera. Incredible!
So rallymax, your original post was in fact correct. Why the version of FFDShow that I first downloaded didn't install the correct dll the first time is still a mystery, but whatever...
That solved the problem. PP now plays the video clip fine, as well as all the other "AVI" (MJPEG) clips from my Canon camera. Incredible!
So rallymax, your original post was in fact correct. Why the version of FFDShow that I first downloaded didn't install the correct dll the first time is still a mystery, but whatever...
December 4, 2010
use .htaccess to protect your web folder
Generate the password file
htpasswd -c .htpasswd fred (where fred is the username you want to use). You'll be prompted to enter and retype your password, then the
.htpasswd file will be created for you.public_html or htdocs folder. (Having said this, Apache is often set up by default to block web-based access to files beginning with .ht. Better safe than sorry though!)If you can't place your
.htpasswd file outside your Web root, name it something that's not easily guessable - for example, .htxuymwp - so that people won't be able to find it easily. (In addition, it helps to start the filename with .ht; as mentioned earlier, Apache usually blocks access to files starting with .ht.)Creating the .htaccess file
Protecting a folder
To password protect a folder on your site, you need to put the following code in your.htaccess file:
AuthUserFile /full/path/to/.htpasswd
AuthType Basic
AuthName "My Secret Folder"
Require valid-user
/full/path/to/.htpasswd should be the full path to the .htpasswd file that you uploaded earlier. The full path is the path to the file from the Web server's volume root - for example, /home/username/.htpasswd or C:\wwwroot\username\.htpasswd. (If you're not sure of the full path to your site or home directory, ask your Web hosting company for this info.)The above
.htaccess file will password protect all files in the folder that it is placed in, and all sub-folders under that folder too. So if you wanted to password protect your entire site, you would place the .htaccess file in your Web root folder.Protecting a file
To password protect just a single file in a folder, use the following.htaccess file:
AuthUserFile /full/path/to/.htpasswd
AuthType Basic
AuthName "My Secret Page"
<Files "mypage.html">
Require valid-user
</Files>
This will password protect just the mypage.html file in the folder where you put the .htaccess file.
December 3, 2010
Export Audio from Windows Movie Maker
In Windows Movie Maker....
To save only the audio track of a video clip...
drag the video to the "Audio/Music" track.
Then go to...File > Publish Movie and you'll get options
for audio quality and save it to a wma audio file.
This will result in a .wma audio file. Be sure
to drag the clip all the way to the left on the
timeline or you will have dead air at the
beginning.
To save only the audio track of a video clip...
drag the video to the "Audio/Music" track.
Then go to...File > Publish Movie and you'll get options
for audio quality and save it to a wma audio file.
This will result in a .wma audio file. Be sure
to drag the clip all the way to the left on the
timeline or you will have dead air at the
beginning.
December 1, 2010
How to turn a Windows application into Windows Service
http://www.tacktech.com/display.cfm?ttid=197
The Windows NT/2000 Resource Kit provides two utilities that allow you to create a Windows user-defined service for Windows applications and some 16-bit applications (but not for batch files).
Whats needed for Windows NT/2000:
Instrsrv.exe installs and removes system services from Windows NT/2000
Srvany.exe allows any Windows application to run as a service.
You can download both files here srvany.zip
This zip includes three files. The two you need srvany.exe and instsrv.exe to install the services and also srvany.wri which documents everything you can do with the program.
Note: Make sure the Services Manager is closed while running the DOS commands.
You will need to put these files in a directory called reskit At a MS-DOS command prompt(Start | Run | "cmd.exe"), type the following command:
<path>\reskit\INSTSRV.EXE "Service Name" <path>\reskit\SRVANY.EXE
This creates the service in the Services manager and the registry keys to setup what program to run.
Next open regedit.exe Start | run | regedit.exe
Next navigate to this registry key.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\service name
From the Edit menu, click Add Key and name it Parameters
Next from the Edit menu, click Add Value and type this information.
Value Name: Application
Data Type : REG_SZ
String : <path>\<application.ext>
Now you can start your service from the Service Manager
With this same program you can remove the service also. Just run this command from command prompt.
<path>\reskit\INSTSRV.EXE "Service Name" REMOVE
The Windows NT/2000 Resource Kit provides two utilities that allow you to create a Windows user-defined service for Windows applications and some 16-bit applications (but not for batch files).
Whats needed for Windows NT/2000:
Instrsrv.exe installs and removes system services from Windows NT/2000
Srvany.exe allows any Windows application to run as a service.
You can download both files here srvany.zip
This zip includes three files. The two you need srvany.exe and instsrv.exe to install the services and also srvany.wri which documents everything you can do with the program.
Note: Make sure the Services Manager is closed while running the DOS commands.
You will need to put these files in a directory called reskit At a MS-DOS command prompt(Start | Run | "cmd.exe"), type the following command:
<path>\reskit\INSTSRV.EXE "Service Name" <path>\reskit\SRVANY.EXE
This creates the service in the Services manager and the registry keys to setup what program to run.
Next open regedit.exe Start | run | regedit.exe
Next navigate to this registry key.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\service name
From the Edit menu, click Add Key and name it Parameters
Next from the Edit menu, click Add Value and type this information.
Value Name: Application
Data Type : REG_SZ
String : <path>\<application.ext>
Now you can start your service from the Service Manager
With this same program you can remove the service also. Just run this command from command prompt.
<path>\reskit\INSTSRV.EXE "Service Name" REMOVE
November 30, 2010
Free online screen sharing website
http://www.mikogo.com/
If you couple this with freeconference.com, you've got a free webcast solution. :-)
If you couple this with freeconference.com, you've got a free webcast solution. :-)
To map a list of addresses
If you have a list of addresses you want to map, you can use Google Fusion Tables. Just import your EXCEL file and tell it which column is address, it will do the rest. Great product.
November 25, 2010
November 23, 2010
qq protocol analysis
the popular QQ protocol is reimplemented by open source community at eva.sourceforge.net, it is also known as libeva.
libeva is used by gaim, miranda and others for adding support to QQ.
The QQ packet is encrypted using TEA algorithm. The session key is created when login. The KEK (key encryption key) is MD5(MD5(password)), and another layer of trivial hard-coded key TEA encryption. In order to sniff QQ, one has to know the login password and therefore to derive the session key.
libeva is used by gaim, miranda and others for adding support to QQ.
The QQ packet is encrypted using TEA algorithm. The session key is created when login. The KEK (key encryption key) is MD5(MD5(password)), and another layer of trivial hard-coded key TEA encryption. In order to sniff QQ, one has to know the login password and therefore to derive the session key.
libyahoo2 for yahoo messenger
library to write your own yahoo messenger or understand the yahoo protocol:
http://libyahoo2.sourceforge.net/
http://libyahoo2.sourceforge.net/
November 21, 2010
google app email server setup
If you use a hosting company and use gmail app, in order to receive email correctly, you need to do two things:
1. set MX record of your domain to gmail app, see <creating mx records> at gmail app help. The current mx records are:
2. create SPF record, i.e. a 'TXT' entry on your domain DNS, with value as:
"v=spf1 include:_spf.google.com ~all"
The second thing is to prevent spam. It is required by google app, otherwise you mail will be bounced.
1. set MX record of your domain to gmail app, see <creating mx records> at gmail app help. The current mx records are:
| Priority | Mail server |
|---|---|
| 1 | ASPMX.L.GOOGLE.COM |
| 5 | ALT1.ASPMX.L.GOOGLE.COM |
| 5 | ALT2.ASPMX.L.GOOGLE.COM |
| 10 | ASPMX2.GOOGLEMAIL.COM |
| 10 | ASPMX3.GOOGLEMAIL.COM |
2. create SPF record, i.e. a 'TXT' entry on your domain DNS, with value as:
"v=spf1 include:_spf.google.com ~all"
The second thing is to prevent spam. It is required by google app, otherwise you mail will be bounced.
November 14, 2010
November 12, 2010
grep with less and color
When you simply run
You can add these to your bashrc aliases:
alias grep='grep --color=always'
alias less='less -R'
grep --color it implies grep --color=auto which detects whether the output is a terminal and if so enables colors. However, when it detects a pipe it disables coloring. The following command:grep --color=always -R "search string" * | less -RWill always enable coloring and override the automatic detection, and you will get the color highlighting in less.You can add these to your bashrc aliases:
alias grep='grep --color=always'
alias less='less -R'
ubuntu install security updates only
just run:
sudo unattended-upgrade
config file is located at: /etc/apt/apt.conf.d/50unattended-upgrades
This command will enable the automatic security update:
sudo dpkg-reconfigure -plow unattended-upgrades
sudo unattended-upgrade
config file is located at: /etc/apt/apt.conf.d/50unattended-upgrades
This command will enable the automatic security update:
sudo dpkg-reconfigure -plow unattended-upgrades
November 11, 2010
vim: list of color groups
In Vim, to see a list of color groups, use
:hi
or the complicated version:
:so $VIMRUNTIME/syntax/hitest.vim
Then you can use the group name in :match command
:help \bar to see multiple string match
For Example, the following command highlights ring or later using the color-group DiffText
:match DiffText /ring\|later/
:hi
or the complicated version:
:so $VIMRUNTIME/syntax/hitest.vim
Then you can use the group name in :match command
:help \bar to see multiple string match
For Example, the following command highlights ring or later using the color-group DiffText
:match DiffText /ring\|later/
November 4, 2010
Drop Linux kernel Cache to make your memory really free
drop_caches
Submitted by admin on Wed, 2006-05-31 16:12 Writing to this will cause the kernel to drop clean caches, dentries and inodes from memory, causing that memory to become free.To free pagecache:
- echo 1 > /proc/sys/vm/drop_caches
- echo 2 > /proc/sys/vm/drop_caches
- echo 3 > /proc/sys/vm/drop_caches
This tunable was added in 2.6.16.
October 19, 2010
October 8, 2010
Difference between typedef and define in C
here are two differences between define and typedef.
Firstly, typedef obeys scoping rules just like variables, whereas define
stays valid until the end of the file (or until a matching undef).
Secondly, some things can be done with typedef that cannot be done with define.
Examples:
Source: http://www.go4expert.com/forums/showthread.php?t=13405
Firstly, typedef obeys scoping rules just like variables, whereas define
stays valid until the end of the file (or until a matching undef).
Secondly, some things can be done with typedef that cannot be done with define.
Examples:
Code:
typedef int* int_p1; int_p1 a, b, c; // a, b, and c are all int pointers. #define int_p2 int* int_p2 a, b, c; // only the first is a pointer!
Code:
typedef int a10[10]; a10 a, b, c; // create three 10-int arrays
Code:
typedef int (*func_p) (int);
func_p fp // func_p is a pointer to a function that
// takes an int and returns an intSource: http://www.go4expert.com/forums/showthread.php?t=13405
September 21, 2010
yahoo imap and STMP server, FREE to ALL
According to Wikipedia, Yahoo has free IMAP services.
"Free IMAP and SMTPs access
It is possible to get direct IMAP access without signing up for paid access nor using software like YPOPs! or FreePOPs. Yahoo operates IMAP servers (imap.mail.yahoo.com in particular), which are globally accessible. However they require a specific, but non-standard IMAP command to be sent before login is done. The command is: “ID ("GUID" "1")” and it is relatively easy to modify any email client to send it. In fact this is the method currently employed by YPOPSs! and FreePOPs. There are modified version of Mutt and Mozilla Thunderbird available that send this command.[23]
There is also an IMAPs server running at imap-ssl.mail.yahoo.com. It is using SSL on the standard port 993.
In addition it is also possible to send mail through mail clients as yahoo also operates an SMTP server (smtp.mail.yahoo.com). It is necessary to enable SSL through port 465. The username is the user's Yahoo mail address and the password is the same as for webmail access, this applies to both IMAP and SMTPs access.yahoo mail address and th e password is the same as for webmail access, the applies to both IMAP and amtps access."
"Free IMAP and SMTPs access
It is possible to get direct IMAP access without signing up for paid access nor using software like YPOPs! or FreePOPs. Yahoo operates IMAP servers (imap.mail.yahoo.com in particular), which are globally accessible. However they require a specific, but non-standard IMAP command to be sent before login is done. The command is: “ID ("GUID" "1")” and it is relatively easy to modify any email client to send it. In fact this is the method currently employed by YPOPSs! and FreePOPs. There are modified version of Mutt and Mozilla Thunderbird available that send this command.[23]
There is also an IMAPs server running at imap-ssl.mail.yahoo.com. It is using SSL on the standard port 993.
In addition it is also possible to send mail through mail clients as yahoo also operates an SMTP server (smtp.mail.yahoo.com). It is necessary to enable SSL through port 465. The username is the user's Yahoo mail address and the password is the same as for webmail access, this applies to both IMAP and SMTPs access.yahoo mail address and th e password is the same as for webmail access, the applies to both IMAP and amtps access."
Source(s):
September 17, 2010
Cross Compile cherokee 1.0.8 to ARM
ac_cv_func_malloc_0_nonnull=yes \
ac_cv_func_realloc_0_nonnull=yes \
./configure \
--host=arm-linux \
--disable-readdir_r \
--disable-tls \
--enable-static-module=all \
--enable-trace \
--enable-static \
--enable-shared=no \
--enable-beta \
--disable-ipv6 \
CC=arm-linux-gcc
make
you will get an errro about readdir_mutex.
go to file cherokee/util.c line 400, changed it to:
now you are good to go, just type make and the final files are in cherokee/{cherokee,cherokee-worker}
To run Cherokee on an embedded platform:
1. download cherokee-worker, cherokee
2. create a conf file with the following contents:
3. create a themes directory with the followings files:
4. run it "./cherokee -C cherokee.conf"
You can enable tracing to see the traces of cherokee.
ac_cv_func_realloc_0_nonnull=yes \
./configure \
--host=arm-linux \
--disable-readdir_r \
--disable-tls \
--enable-static-module=all \
--enable-trace \
--enable-static \
--enable-shared=no \
--enable-beta \
--disable-ipv6 \
CC=arm-linux-gcc
make
you will get an errro about readdir_mutex.
go to file cherokee/util.c line 400, changed it to:
#if defined(HAVE_PTHREAD)
now you are good to go, just type make and the final files are in cherokee/{cherokee,cherokee-worker}
To run Cherokee on an embedded platform:
1. download cherokee-worker, cherokee
2. create a conf file with the following contents:
server!bind!1!port = 80
server!timeout = 60
server!keepalive = 1
server!keepalive_max_requests = 500
server!server_tokens = full
#server!encoder!gzip!allow = html,html,txt,css,js
server!panic_action = /web/cherokee-panic
server!pid_file = /var/run/cherokee.pid
server!user = root
server!group = root
# Default virtual server
#
vserver!default!nick = default
vserver!default!document_root = /web
vserver!default!directory_index = index.php,index.html
vserver!default!logger = combined
vserver!default!logger!access!type = file
vserver!default!logger!access!filename = /var/log/cherokee.access
vserver!default!logger!access!buffsize = 16384
vserver!default!logger!error!type = file
vserver!default!logger!error!filename = /var/log/cherokee.error
vserver!default!rule!1!match = default
vserver!default!rule!1!handler = common
vserver!default!rule!1!handler!iocache = 0
vserver!default!rule!99999!match = extensions
vserver!default!rule!99999!match!extensions = php
vserver!default!rule!99999!handler = fcgi
vserver!default!rule!99999!handler!balancer = round_robin
vserver!default!rule!99999!handler!balancer!type = interpreter
vserver!default!rule!99999!handler!balancer!source!1 = 1
vserver!default!rule!99999!handler!balancer!local1!host = 127.0.0.1:1234
vserver!default!rule!99999!handler!balancer!local1!env!PHP_FCGI_CHILDREN = 5
vserver!default!rule!99999!handler!balancer!local1!interpreter = /web/php-cgi -b 1234
source!1!env!PHP_FCGI_CHILDREN = 5
source!1!host = 127.0.0.1:1234
source!1!interpreter = /web/php-cgi -b 1234
source!1!nick = php
#source!1!type = interpreter
source!1!type = host
3. create a themes directory with the followings files:
ls themes/default/
theme.css logo.png header.html footer.html entry.html
4. run it "./cherokee -C cherokee.conf"
You can enable tracing to see the traces of cherokee.
September 15, 2010
September 14, 2010
September 3, 2010
Determine your linux distribution version
Use 'uname -a' to get kernel info
Use 'cat /etc/redhat-release' to find out redhat/FC release info
Use 'cat cat /etc/debian_version' to find out debian release info
Ubuntu? Just use debian. :-)
Use 'cat /etc/redhat-release' to find out redhat/FC release info
Use 'cat cat /etc/debian_version' to find out debian release info
Ubuntu? Just use debian. :-)
List of VOIP phone and their codecs
This table is from http://www.ozvoip.com/voip-codecs/devices/
| Client | Supported Codecs |
|---|---|
| Billion BIPAC 7402VL | G.711, G.729 |
| Billion BIPAC-7100SV | G.711, G.729 |
| Billion BIPAC7402VGP | G.711, G.729 |
| Cisco 7960 | G.711, G.729 |
| Draytek Vigor 2100V(G) | G.711, G.723.1, G.726, G.729 |
| Draytek Vigor 2500V | G.711, G.729 |
| Draytek Vigor 2600V(G) | G.711, G.723.1, G.726, G.729 |
| Draytek Vigor 2900V(G) | G.711, G.723.1, G.726, G.729 |
| eyeBeam | GSM, iLBC, G.711, G.722, G.723.1, G.729, Speex |
| Grandstream BudgeTone 101 | iLBC, G.711, G.723.1, G.726, G.728, G.729 |
| Grandstream BudgeTone 102 | iLBC, G.711, G.723.1, G.726, G.728, G.729 |
| Grandstream GXP2000 | GSM, G.711, G.722, G.723.1, G.726, G.728, G.729 |
| Grandstream HandyTone 286 | iLBC, G.711, G.723.1, G.726, G.728, G.729 |
| Grandstream Handytone 486 | iLBC, G.711, G.723.1, G.726, G.728, G.729 |
| Leadtek 8051 | G.711, G.723.1, G.726, G.729 |
| Linksys PAP2 | G.711, G.723.1, G.726, G.729 |
| Linksys RT31P2 | G.711, G.723.1, G.726, G.729 |
| Linksys WRT54GP2 | G.711, G.729 |
| MS Office Communicator | GSM, G.711, G.722, G.723.1, DVI4, Siren |
| Octtel SPxxxx Series Gateways | G.711, G.729 |
| Polycom SoundPoint IP300 | G.711, G.729 |
| Polycom SoundPoint IP500 | G.711, G.729 |
| Polycom SoundPoint IP600 | G.711, G.729 |
| Siemens optiPoint 400 Family | G.723.1 |
| Siemens optiPoint 410 Family | G.711, G.723.1 |
| Siemens optiPoint 420 Family | G.711, G.722, G.723.1, G.729 |
| Sipura SPA-2000 | G.711, G.723.1, G.726, G.729 |
| Sipura SPA-2100 | G.711, G.723.1, G.726, G.729 |
| Sipura SPA-3000 | G.711, G.723.1, G.726, G.729 |
| Sipura SPA-841 | G.711, G.729 |
| sipXphone | G.711 |
| SJPhone (free version) | GSM, iLBC, G.711 |
| Snom 190 | GSM, G.711, G.722, G.723.1, G.726, G.729 |
| Snom 320 | GSM, G.711, G.722, G.723.1, G.726, G.729 |
| Snom 360 | GSM, G.711, G.722, G.723.1, G.726, G.729 |
| SwissVoice IP 10S | iLBC, G.729 |
| Uniden UIP-200 | G.711, G.729 |
| Windows Messenger | GSM, G.711, G.722, G.723.1, DVI4, Siren |
| X-lite | GSM, iLBC, G.711, Speex |
| X-Pro | GSM, iLBC, G.711, G.729, Speex |
| Zyxel Prestige 2000W | G.711, G.729 |
| Zyxel Prestige 2002 | G.711, G.729 |
| Zyxel Prestige 2602HW(-L) | G.711, G.729 |
September 2, 2010
Asterisk SIP PBX simple tutorial / quick start guide
Recently I start to investigate how to make asterisk to be an SIP BPX with small foot print, and I have a running SIP PBX now. Below are the notes on how I got it to run.
Platform: I am running asterisk in Colinux under Windows Vista. Debian 5 is running in Colinux.
Short summary:
version: asterisk 1.4 is stable and used widely. 1.6 is considered short-term support. Supposedly 1.8 is another stable version for long-term support. I use 1.4
source : the source tar gzip of asterisk is about 23MB. It uses the standard "./configure;make;make install" procedure to compile. See README in source tar ball.
structure: asterisk uses a lot of ".so" dynamic libraries, which are called modules and are loaded dynamically when program starts. Which one to load or not to load is controlled by the file "modules.conf". Many of the modules are essential to make asterisk useful, while others are optional for our purpose.
directories: configurations are under /etc/asterisk, modules (dynamic library files are under /usr/lib/asterisk/modules). Other directories are determined in compile-time and are listed in "asterisk.conf"
configurations: Unlike most unix programs, "asterisk.conf" is not what you change the most. In fact, you can probably leave it as is. The files we need to change the most for making a IP PBX are:
Platform: I am running asterisk in Colinux under Windows Vista. Debian 5 is running in Colinux.
Short summary:
version: asterisk 1.4 is stable and used widely. 1.6 is considered short-term support. Supposedly 1.8 is another stable version for long-term support. I use 1.4
source : the source tar gzip of asterisk is about 23MB. It uses the standard "./configure;make;make install" procedure to compile. See README in source tar ball.
structure: asterisk uses a lot of ".so" dynamic libraries, which are called modules and are loaded dynamically when program starts. Which one to load or not to load is controlled by the file "modules.conf". Many of the modules are essential to make asterisk useful, while others are optional for our purpose.
directories: configurations are under /etc/asterisk, modules (dynamic library files are under /usr/lib/asterisk/modules). Other directories are determined in compile-time and are listed in "asterisk.conf"
configurations: Unlike most unix programs, "asterisk.conf" is not what you change the most. In fact, you can probably leave it as is. The files we need to change the most for making a IP PBX are:
- modules.conf ; for configuring which modules to load or not load
- sip.conf ; for configuring all sip channels, both external and internal
- extensions.conf; the heart of the PBX, configures what key press/ what extension does what
- apt-get install asterisk
- /etc/init.d/asterisk stop. I like to use console for getting thing to run. so stop the daemon
- copy modules.conf below as your modules.conf
- copy sip.conf as your sip.conf. I use sipgate as my provider. ( I tested incoming call and outgoing call to toll-free numbers)
- copy extensions.conf to yours.
- start your asterisk in console mode (asterisk -cvvv)
- install x-lite software phone on your Windows and configure it as follows:
- now you can dial 123 to hear the playback voice from asterisk. go to asterisk CLI, and type "sip show peers" and you should see two peers, your sipgate and your x-lite phone.
- You can now make calls and receive calls.
- For further reading, I recommend the O'reilly book "Asterisk".
Free U.S.domestic phone number
You can get it from any of the following providers:
1. Google voice
2. SipGate
3. IPKall
4. IPComms (http://www.ipcomms.net/product-freedid.html)
I use Google voice and SipGate. Any one has used IPComms?
1. Google voice
2. SipGate
3. IPKall
4. IPComms (http://www.ipcomms.net/product-freedid.html)
I use Google voice and SipGate. Any one has used IPComms?
September 1, 2010
voip codecs and bps

- g.711 is raw data, highest quality, but requires highest bandwidth
- g.729a is the next best, very good quality, very low datarate, but it requires a $10 license per channel for asterisk. There is a free version for research and education use at http://asterisk.hosting.lv/
- iLBC may be the next best, it is free, good quality, and relatively low datarate. Go to this link to find out how to add iLBC back to Asterisk. Remember, you will need to copy the original Makefile in the ilbc folder to the new ilbc folder.
- GSM quality is acceptable, but not very good.
- G722 is wide band, hi-def stuff.
Real bps numbers:
- GSM: 30kbps
- g711: 80kbps
- iLBC: 30kbps
- g729: 30kbps (why it is this high? bps seen by bwm-ng)
* G.729 (NOT G.729a) has a MOS of 3.9-4.2 and uses 24 kbps @ 20 ms or 18.7 kbps @ 30 ms.
* G.729a has a MOS of 3.7-4.2 and uses 24 kbps @ 20 ms or 18.7 kbps @ 30 ms.
* G.723 has a MOS of 3.8-4.0 and uses 17.1 kbps @ 30 ms.
MOS is what nontechnical people think about each codec (5.0 is perfect). All of the above numbers are in EACH direction, so total bandwidth is double the above figures.
As you can see, there is very little quality or bandwidth difference betweeen G.729a and G.723. However, G.729a can send 50 packets/second, each packet containing 20 ms of voice payload. G.723's lowest setting is 30 ms. I think 20 ms sounds better than 30 ms because of smoothing (used to fill in for late packets). That's why I chose G.729a @ 20 ms over G.723 @ 30 ms for my Sipura adapter. (Sipura's default setting is 20 ms (that is, 'RTP Packet Size' = '0.020').)
It would be a very good idea to turn on silence suppression ('Silence Supp Enable' = 'yes'), because it will reduce your bandwidth usage by 65%. (Apparently each person in a two-person conversation only talks about 1/3 of the time.) With my Sipura 2100, I could not hear any difference between silence suppression being on or off.
G729 uses less compression (less latency problems) and has a higher level of voice quality BUT does use more bandwidth. I personally am not fond of g723.1 but usually find g729 to be OK. Some people despise both.
Packet8 started using g723.1 and later switched to g729 most likely due to customer complaints about the poor quality of g723.1 calls.
How to upgrade SPA942 IP Phone internal directory using wget
See the post here:
http://blog.grimsy.net/2007/02/23/spa942-personal-directory/
A Recap:
After trying a number of things, I upgraded to the latest firmware (5.1.5 at time of writing) and after some more stuffing around, I was finally able to get the following line to populate the Personal Directory:
A few things about the command.
Firstly, the command will enter in two contacts in the Directory. These will be under entry #5 (24686) and entry #2 (25390). A complete list of all the codes here can be seen in the source of the Personal Directory page in the phone’s web interface.
So taking the first of the two entries (24686), what we’re posting is:
n=Geoff; (we need to escape the ‘=’ signs so that wget will actually pass the info on correctly)
n is the Display Name that will appear in the Directory
p=6004;
p is the extension number (or phone number). My extension is 6004.
r=1
r is the ring to use. 0 is no sound, just flashing. Play around with the other numbers to find the ringtone you want to use.
To add more than one entry at a time, simply separate the strings with ‘&’.
http://blog.grimsy.net/2007/02/23/spa942-personal-directory/
A Recap:
After trying a number of things, I upgraded to the latest firmware (5.1.5 at time of writing) and after some more stuffing around, I was finally able to get the following line to populate the Personal Directory:
wget --post-data '24686=n%3DGeoff;p%3D6004;r%3D1&25390=n%3DMatt;p%3D6001;r%3D1' http://myphoneIP/pdir.spa
A few things about the command.
Firstly, the command will enter in two contacts in the Directory. These will be under entry #5 (24686) and entry #2 (25390). A complete list of all the codes here can be seen in the source of the Personal Directory page in the phone’s web interface.
So taking the first of the two entries (24686), what we’re posting is:
n%3DGeoff;
n is the Display Name that will appear in the Directory
p%3D6004;
p is the extension number (or phone number). My extension is 6004.
r%3D1
r is the ring to use. 0 is no sound, just flashing. Play around with the other numbers to find the ringtone you want to use.
To add more than one entry at a time, simply separate the strings with ‘&’.
August 31, 2010
mini2440 flash upgrade
How to upgrade mini2440/micro2440 kernel image after the systems boots to Linux:
killall processes
mount -o remount,ro /
cd /dev/shm
flash_erase /dev/mtd1 0 16
nandwrite -a -p /dev/mtd1 /zImage_new
Bootloader
There are two "official" bootloaders, supervivi-128M and viv. supervivi is a little bit less than 256K (0x40000), while vivi is only 3-4K. We have supervivi in NOR flash, and viv in NAND flash.
0x0,00000 - 0x0,40000 bootloader
0x0,48000 - 0x0,60000 bootloader parameters (linux_cmd_line starts at 0x48000 and ends with the first 0x0)
0x0,60000 - 0x2,60000 2M of kernel space
0x2,60000 - 0x80,00000 close to 126M application image
Tools to read/write/erase flash after system is booted (all in mtd-utils project):
- flash_erase
- nandwrite
- nanddump
- mtd_debug
echo -n -e "VIVICMDLnoinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0\0000" > /tmp/cmdline
/cmdc/flash_erase /dev/mtd0 0x40000 1
/cmdc/nandwrite -p /dev/mtd0 -s 0x48000 /tmp/cmdline
You can probably use the same nandwrite to update the bootloader itself. I haven't tried that yet.
killall processes
mount -o remount,ro /
cd /dev/shm
flash_erase /dev/mtd1 0 16
nandwrite -a -p /dev/mtd1 /zImage_new
Bootloader
There are two "official" bootloaders, supervivi-128M and viv. supervivi is a little bit less than 256K (0x40000), while vivi is only 3-4K. We have supervivi in NOR flash, and viv in NAND flash.
0x0,00000 - 0x0,40000 bootloader
0x0,48000 - 0x0,60000 bootloader parameters (linux_cmd_line starts at 0x48000 and ends with the first 0x0)
0x0,60000 - 0x2,60000 2M of kernel space
0x2,60000 - 0x80,00000 close to 126M application image
Tools to read/write/erase flash after system is booted (all in mtd-utils project):
- flash_erase
- nandwrite
- nanddump
- mtd_debug
echo -n -e "VIVICMDLnoinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0\0000" > /tmp/cmdline
/cmdc/flash_erase /dev/mtd0 0x40000 1
/cmdc/nandwrite -p /dev/mtd0 -s 0x48000 /tmp/cmdline
You can probably use the same nandwrite to update the bootloader itself. I haven't tried that yet.
Export MySQL database to CSV file
SELECT * INTO OUTFILE '/tmp/result.text'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM test_table;
And the results are sent to /tmp/result.text in CSV format.
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM test_table;
And the results are sent to /tmp/result.text in CSV format.
August 27, 2010
Thunderbird turn off signature in reply emails
August 23, 2010
defishing an image
Open source software: Hugin/Nona
http://www.pentaxforums.com/forums/pentax-slr-lens-discussion/33634-how-do-you-de-fish.html
http://wiki.panotools.org/Hugin
http://www.flickr.com/groups/67669253@N00/discuss/72157594344672391/
http://sourceforge.net/projects/hugin/files/hugin/
http://www.pbase.com/troyz/defishing_examples
http://www.pentaxforums.com/forums/pentax-slr-lens-discussion/33634-how-do-you-de-fish.html
http://wiki.panotools.org/Hugin
http://www.flickr.com/groups/67669253@N00/discuss/72157594344672391/
http://sourceforge.net/projects/hugin/files/hugin/
http://www.pbase.com/troyz/defishing_examples
August 17, 2010
Remove blank/empty lines from a file
There are many ways to do it:
- grep '.' file > newfile
- awk '/./' file > newfile
August 14, 2010
Vim embedded command in the file edited
This is called "modeline" in vim. you can file help on that.
http://vim.wikia.com/wiki/Modeline_magic
First, make sure modeline is enabled. Then
http://vim.wikia.com/wiki/Modeline_magic
First, make sure modeline is enabled. Then
The following examples show some alternatives that could be in a C file:
// vim: noai:ts=4:sw=4
-or-
/* vim: noai:ts=4:sw=4
*/
-or-
/* vim: set noai ts=4 sw=4: */
-or-
/* vim: set fdm=expr fde=getline(v\:lnum)=~'{'?'>1'\:'1': */
With "set", the modeline ends at the first colon not following a backslash. Without "set", no text can follow the options, so for example, the following is invalid:
Error E518: Unknown option: */
/* vim: noai:ts=4:sw=4 */
August 10, 2010
Disable ssh server reverse dns lookup
Add/Edit the following lines to your /etc/ssh/sshd_config and restart ssh service
UseDNS no
GSSAPIAuthentication no
GatewayPorts yes
UseDNS no
GSSAPIAuthentication no
To enable remote port forwarding for all the computers on your subnet, add this:
August 5, 2010
Open source Windows TCP Serial port server
Download the Serproxy zip source code , and compile it using the following Makefile using mingw-32.
#
# File:Windows serproxy makefile
#
# (C)1999 Stefano Busti
#
VERSION = `cat VERSION`
SRCS = \
main.c sio.c sock.c thread.c vlist.c cfglib.c config.c string.c \
pipe.c error.c
OBJS = \
main.o sio.o sock.o thread.o vlist.o cfglib.o config.o string.o \
pipe.c error.c
CC = gcc
ifdef DEBUG
CFLAGS = -Wall -g -D__UNIX__ -DDEBUG
else
CFLAGS = -Wall -O2 -fomit-frame-pointer -D__WIN32__ -DWINTHREADS -DSOCK_WIN -DSIO_WIN32
endif
ifdef USE_EF
#LIBS= -lpthread -lefence
else
#LIBS= -lpthread
endif
LIBS=-lws2_32
# Build the program
serproxy: $(SRCS) $(OBJS)
$(CC) $(CFLAGS) -o serproxy $(OBJS) $(LDFLAGS) $(LIBS)
install: serproxy
cp -f serproxy /usr/local/bin
clean:
rm -f *.o *~
realclean:
rm -f *.o *~ serproxy *.gz *.zip
dep:
makedepend -Y -- $(CFLAGS) -- $(SRCS) 2&>/dev/null
# DO NOT DELETE
main.o: sio.h sock.h pipe.h thread.h vlist.h cfglib.h config.h error.h
sio.o: sio.h
sock.o: sock.h
thread.o: thread.h
vlist.o: vlist.h
cfglib.o: cfglib.h
config.o: config.h cfglib.h string.h
string.o: string.h
pipe.o: pipe.h sio.h sock.h thread.h
error.o: error.h
Cross Compile PHP 5.3.3 to ARM
Updated on 2012/05/08 for Compiling PHP 5.4.2 enabling FPM (fastcgi)
1. ./configure --host=arm-linux --without-pear --disable-simplexml --disable-mbregex --enable-sockets --enable-pdo --with-pdo-sqlite --with-sqlite3 --disable-all
2. vi Makefile, search for "-lcrypt", add "-ldl" to the same line.
3. make -j 12
4. php-cgi is in sapi/cgi.
5. use arm-linux-strip php-cgi to strip out the symbols
Done.
-- To compile PHP 5.4.2 with FPM enabled--
1. First edit the "configure" file to remove checking of ptrace and proc mem file (both should be set to yes, broken_ptrace set to no). If you don't need FPM, no change to configure script is necessary.
My new version of this section looks like this:
have_broken_ptrace=no
have_ptrace=yes
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ptrace works" >&5
$as_echo_n "checking whether ptrace works... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
if test "$have_ptrace" = "yes"; then
$as_echo "#define HAVE_PTRACE 1" >>confdefs.h
fi
...
Done.
1. ./configure --host=arm-linux --without-pear --disable-simplexml --disable-mbregex --enable-sockets --enable-pdo --with-pdo-sqlite --with-sqlite3 --disable-all
2. vi Makefile, search for "-lcrypt", add "-ldl" to the same line.
3. make -j 12
4. php-cgi is in sapi/cgi.
5. use arm-linux-strip php-cgi to strip out the symbols
Done.
-- To compile PHP 5.4.2 with FPM enabled--
1. First edit the "configure" file to remove checking of ptrace and proc mem file (both should be set to yes, broken_ptrace set to no). If you don't need FPM, no change to configure script is necessary.
My new version of this section looks like this:
have_broken_ptrace=no
have_ptrace=yes
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ptrace works" >&5
$as_echo_n "checking whether ptrace works... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
if test "$have_ptrace" = "yes"; then
$as_echo "#define HAVE_PTRACE 1" >>confdefs.h
fi
...
proc_mem_file="mem"
if test -n "$proc_mem_file" ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for proc mem file" >&5
$as_echo_n "checking for proc mem file... " >&6; }
if test "$cross_compiling" = no; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $proc_mem_file" >&5
$as_echo "$proc_mem_file" >&6; }
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
fi
2. CC=arm-none-linux-gnueabi-gcc ./configure --host=arm-linux --without-pear --disable-simplexml --disable-mbregex --enable-sockets --enable-pdo --with-pdo-sqlite --with-sqlite3 --enable-fpm --disable-all
3. make -j 12
4. php-fpm is at sapi/cgi
5. use arm-linux-strip php-fpm to strip out the symbols
Done.
August 1, 2010
Subscribe to:
Posts (Atom)


