http://linux.about.com/od/linux101/l/blnewbie5_1.htm
http://www.unixguide.net/linux/linuxshortcuts.shtml
Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts
Friday, December 18, 2009
Monday, June 22, 2009
Monday, November 24, 2008
Batch Convert UTF-8
For i18n, multi-language web content, there is always confusion about text encoding standard, namely English(ISO-8859-1), Chinese(simplied chinese in GB2312 or traditional chinese in BIG5 format) and UTF-8.
At this point of time, I couldn't find a convinient tool to conviniently convert other encoding standards into UTF-8.
The following Unix command can do the job - iconv
To batch convert all files under the current directory, here's the combination:
find . -name "*.php" -exec iconv -f ISO-8859-1 -t utf-8 {} -o {}.new \;
Note the " \;" (that's _space_\; ... It's essential. )
Source: http://www.webmasterworld.com/forum40/1537.htm
At this point of time, I couldn't find a convinient tool to conviniently convert other encoding standards into UTF-8.
The following Unix command can do the job - iconv
To batch convert all files under the current directory, here's the combination:
find . -name "*.php" -exec iconv -f ISO-8859-1 -t utf-8 {} -o {}.new \;
Note the " \;" (that's _space_\; ... It's essential. )
Source: http://www.webmasterworld.com/forum40/1537.htm
Friday, March 30, 2007
Shell script execution - command not found, syntax error near unexpected token
When we edit shell script in Windows machine, and ftp it to Linux for execution, sometimes we hit the following error:
“command not foundh” line xxx
“command not foundne” line xxx: syntax error near unexpected token `
This is due to the newline characters used on both systems. We need to replace all occurances of "\r\n" with "\n".
In vi, do the following:
// Change from(DOS) to just (Unix):
:set fileformat=unix
:w
// change back to Carriage Return + Line Feed for DOS
:set fileformat=dos
:w
// writing for apple computers:
:set fileformat=mac
:w
// remove multiple (repeated) Carriage Returns using search and replace
:%s/[^M]$//
:w
“command not foundh” line xxx
“command not foundne” line xxx: syntax error near unexpected token `
This is due to the newline characters used on both systems. We need to replace all occurances of "\r\n" with "\n".
In vi, do the following:
// Change from
:set fileformat=unix
:w
// change back to Carriage Return + Line Feed for DOS
:set fileformat=dos
:w
// writing for apple computers:
:set fileformat=mac
:w
// remove multiple (repeated) Carriage Returns using search and replace
:%s/[^M]$//
:w
Friday, December 08, 2006
Burning CD for Linux and in Linux
Reference:
1. http://linuxlab.dk/tipsntricks/cdburning
2. http://sourceforge.net/projects/jcdwriter/
Burning CD/DVD for Linux and in Linux is quite a challenging experience.
Oracle softwares are downloaded in cpio format and come in multiple disks. It is disk space and time consuming to extract each cpio each time. So, my idea is to create 1 DVD to consist of all multiple CDs, hence save the trouble to swap disks.
For example, DVD_ROOT:
+ AS1012
+ Disk1
+ Disk2
+ Disk3
+ Disk4
+ AS1013
+ Disk1
Intuitively I simply extracted cpio in Linux, ftp the extracted files to Windows, then use Roxio CD Creator to burn DVD.
Problem: Windows-burned DVD has lost the ownership and execution privilege of all files. I cannot simply “runInstaller” off the DVD. The DVD is useless.
Hence, the next plan is to burn DVD directly on Linux and hope that Linux will keep the correct execution privilege.
By default, Linux has already come with 2 command line utilities to produce CD/DVD:
1. mkisofs - create the iso image of the files.
2. cdrecord - burn CD from iso image.
There are 3 steps to produce CD in Linux:
1. Produce ISO image.
% mkisofs -graft-point -R -J -l -D -o /tmp/filename.iso /AS1012/=/tmp/OracleAS/AS1012/ /AS1013/=/tmp/OracleAS/AS1013/
... where,
-J : Generate Joliet directory records in addition to regular iso9660 file names. This is primarily useful when the discs are to be used on Windows-NT or Windows-95 machines. The Joliet filenames are specified in Unicode and each path component can be up to 64 Unicode characters long.
-l: Allow full 31 character filenames.
-D: Do not use deep directory relocation, and instead just pack them in the way we see them.
The above 3 arguments are necessary. Otherwise default Linux-burned CD will have seriously messed-up filename (capitalized and truncated) and directory structure (relocated deep directory).
2. Detect the CD-Writer.
% cdrecord -scanbus
Cdrecord-Clone 2.01-dvd (i686-pc-linux-gnu) Copyright (C) 1995-2004 JÃrg Schilling
Note: This version is an unofficial (modified) version with DVD support
scsibus2:
2,0,0 200) '_NEC ' 'DVD_RW ND-1300A ' '1.0B' Removable CD-ROM
2,1,0 201) *
2,2,0 202) *
2,3,0 203) *
2,4,0 204) *
2,5,0 205) *
2,6,0 206) *
2,7,0 207) *
3. Burn CD from ISO image.
% cdrecord -v dev=2,0,0 speed=2 --eject /tmp/filename.iso
... where
dev=devicename:scsibus,target,lun is the id of the CD-Writer scanned from step 2.
--eject: Eject after burned CD.
1. http://linuxlab.dk/tipsntricks/cdburning
2. http://sourceforge.net/projects/jcdwriter/
Burning CD/DVD for Linux and in Linux is quite a challenging experience.
Oracle softwares are downloaded in cpio format and come in multiple disks. It is disk space and time consuming to extract each cpio each time. So, my idea is to create 1 DVD to consist of all multiple CDs, hence save the trouble to swap disks.
For example, DVD_ROOT:
+ AS1012
+ Disk1
+ Disk2
+ Disk3
+ Disk4
+ AS1013
+ Disk1
Intuitively I simply extracted cpio in Linux, ftp the extracted files to Windows, then use Roxio CD Creator to burn DVD.
Problem: Windows-burned DVD has lost the ownership and execution privilege of all files. I cannot simply “runInstaller” off the DVD. The DVD is useless.
Hence, the next plan is to burn DVD directly on Linux and hope that Linux will keep the correct execution privilege.
By default, Linux has already come with 2 command line utilities to produce CD/DVD:
1. mkisofs - create the iso image of the files.
2. cdrecord - burn CD from iso image.
There are 3 steps to produce CD in Linux:
1. Produce ISO image.
% mkisofs -graft-point -R -J -l -D -o /tmp/filename.iso /AS1012/=/tmp/OracleAS/AS1012/ /AS1013/=/tmp/OracleAS/AS1013/
... where,
-J : Generate Joliet directory records in addition to regular iso9660 file names. This is primarily useful when the discs are to be used on Windows-NT or Windows-95 machines. The Joliet filenames are specified in Unicode and each path component can be up to 64 Unicode characters long.
-l: Allow full 31 character filenames.
-D: Do not use deep directory relocation, and instead just pack them in the way we see them.
The above 3 arguments are necessary. Otherwise default Linux-burned CD will have seriously messed-up filename (capitalized and truncated) and directory structure (relocated deep directory).
2. Detect the CD-Writer.
% cdrecord -scanbus
Cdrecord-Clone 2.01-dvd (i686-pc-linux-gnu) Copyright (C) 1995-2004 JÃrg Schilling
Note: This version is an unofficial (modified) version with DVD support
scsibus2:
2,0,0 200) '_NEC ' 'DVD_RW ND-1300A ' '1.0B' Removable CD-ROM
2,1,0 201) *
2,2,0 202) *
2,3,0 203) *
2,4,0 204) *
2,5,0 205) *
2,6,0 206) *
2,7,0 207) *
3. Burn CD from ISO image.
% cdrecord -v dev=2,0,0 speed=2 --eject /tmp/filename.iso
... where
dev=devicename:scsibus,target,lun is the id of the CD-Writer scanned from step 2.
--eject: Eject after burned CD.
Subscribe to:
Posts (Atom)