Let's see a small example of a for cycle directly inside the shell:
me@ubuntu:~/workspace/myFile$ for file in *
> do
> echo $file
> grep foo $file
> done
test.txt
hi, my name is foo
In this case we will cycle all the files in the current directory, print out their names and grep "foo" for each one. Of course you can simply make recursive grep with * as file input parameter... but this can be a startup point for more complex operations
Thursday, January 31, 2008
Thursday, January 24, 2008
How to enable speed step on core 2 duo
Before starting we have to discover which governors are avaiable for our processor:
$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
The output should be something like this:
powersave ondemand conservative performance
Considering that in Ubuntu Gusty scaling is supported directly by the kernel we will to do nothing else than load the following modules:
cpufreq_conservative
cpufreq_ondemand
cpufreq_powersave
acpi-cpufreq
To do this we have to add the previous lines to the modules file:
$ sudo gedit /etc/modules
Now we can reboot the machine and enjoy the speed stepping. To set a specif governor we can type cpufreq-selector -g {governor}, here there is an example:
$ cpufreq-selector -g ondemand
We can also add the CPU frequency scaling monitor. To do this right click on the top panel and select Add to panel. Now we can drag & drop the gnome applet. To be able to change the governor from the applet we have to type the following command:
$ sudo chmod +s /usr/bin/cpufreq-selector
$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
The output should be something like this:
powersave ondemand conservative performance
Considering that in Ubuntu Gusty scaling is supported directly by the kernel we will to do nothing else than load the following modules:
cpufreq_conservative
cpufreq_ondemand
cpufreq_powersave
acpi-cpufreq
To do this we have to add the previous lines to the modules file:
$ sudo gedit /etc/modules
Now we can reboot the machine and enjoy the speed stepping. To set a specif governor we can type cpufreq-selector -g {governor}, here there is an example:
$ cpufreq-selector -g ondemand
We can also add the CPU frequency scaling monitor. To do this right click on the top panel and select Add to panel. Now we can drag & drop the gnome applet. To be able to change the governor from the applet we have to type the following command:
$ sudo chmod +s /usr/bin/cpufreq-selector
Friday, December 14, 2007
Jboss - Disable cluster
It could happen that you have two instances of Jboss running inside the same network. By its default configuration Jboss will start to search for other instances around and if it found one it will start clustering. If you want to avoid this you can simply modify the mcast_port or the mcast_port. To do this first you have to identify where this parameters are confiugred:
abba@MyHost /jboss/server/all/deploy $ grep -r mcast *.xml
Doing like that you will have something like this:
cluster-service.xml: UDP mcast_addr="${jboss.partition.udpGroup:228.1.2.3}" mcast_port="5566"
cluster-service.xml: ip_ttl="${jgroups.mcast.ip_ttl:8}" ip_mcast="true"
cluster-service.xml: mcast_recv_buf_size="2000000" mcast_send_buf_size="640000"
ejb3-clustered-sfsbcache-service.xml:
ejb3-clustered-sfsbcache-service.xml: mcast_send_buf_size="150000" mcast_recv_buf_size="80000" ucast_send_buf_size="150000"
ejb3-entity-cache-service.xml:
ejb3-entity-cache-service.xml: mcast_send_buf_size="150000" mcast_recv_buf_size="80000" ucast_send_buf_size="150000"
Now you will have to modify all this file. In my case you can already see that compared to the default jboss configuration I've changed the mcast_port. You will have also to modify another file:
abba@MyHost /jboss/server/all/deploy $ vi META-INF/jboss-service.xml
abba@MyHost /jboss/server/all/deploy $ grep -r mcast *.xml
Doing like that you will have something like this:
cluster-service.xml: UDP mcast_addr="${jboss.partition.udpGroup:228.1.2.3}" mcast_port="5566"
cluster-service.xml: ip_ttl="${jgroups.mcast.ip_ttl:8}" ip_mcast="true"
cluster-service.xml: mcast_recv_buf_size="2000000" mcast_send_buf_size="640000"
ejb3-clustered-sfsbcache-service.xml:
ejb3-clustered-sfsbcache-service.xml: mcast_send_buf_size="150000" mcast_recv_buf_size="80000" ucast_send_buf_size="150000"
ejb3-entity-cache-service.xml:
ejb3-entity-cache-service.xml: mcast_send_buf_size="150000" mcast_recv_buf_size="80000" ucast_send_buf_size="150000"
Now you will have to modify all this file. In my case you can already see that compared to the default jboss configuration I've changed the mcast_port. You will have also to modify another file:
abba@MyHost /jboss/server/all/deploy $ vi META-INF/jboss-service.xml
Tuesday, December 11, 2007
Data extraction from oracle to csv file
First of all we have to create a script (test.sql) to extract our data:
spool test.csv
set colsep ";"
set pagesize 0
set linesize 10000
SELECT A, B, C
FROM TB_AA
INNER JOIN TB_BB
ON TB_BB.ID = TB_AA.EXT_ID
WHERE TB_AA.FOO = 4;
spool off
exit
Once this is done we can use this command to run the script we have just created:
$ sqlplus user/passwor@ @test.sql
At this point we will obtain as result a file (test.csv) in our folder.
spool test.csv
set colsep ";"
set pagesize 0
set linesize 10000
SELECT A, B, C
FROM TB_AA
INNER JOIN TB_BB
ON TB_BB.ID = TB_AA.EXT_ID
WHERE TB_AA.FOO = 4;
spool off
exit
Once this is done we can use this command to run the script we have just created:
$ sqlplus user/passwor@
At this point we will obtain as result a file (test.csv) in our folder.
Change locale & language inside ssh terminal
First you can have an overview of the setting of the system you are working with typing:
$ locale
You will obtain a list of all the avaiable locale setting (language, currecy, date....):
LANG=de_DE.UTF-8
LC_CTYPE="de_DE.UTF-8"
LC_NUMERIC="de_DE.UTF-8"
LC_TIME="de_DE.UTF-8"
LC_COLLATE="de_DE.UTF-8"
LC_MONETARY="de_DE.UTF-8"
LC_MESSAGES="de_DE.UTF-8"
LC_PAPER="de_DE.UTF-8"
LC_NAME="de_DE.UTF-8"
LC_ADDRESS="de_DE.UTF-8"
LC_TELEPHONE="de_DE.UTF-8"
LC_MEASUREMENT="de_DE.UTF-8"
LC_IDENTIFICATION="de_DE.UTF-8"
LC_ALL=
At this point we can modify the language:
$ export LANG=en_UK.UTF-8
Obviously once you will have logged out you will lose all your setting.
$ locale
You will obtain a list of all the avaiable locale setting (language, currecy, date....):
LANG=de_DE.UTF-8
LC_CTYPE="de_DE.UTF-8"
LC_NUMERIC="de_DE.UTF-8"
LC_TIME="de_DE.UTF-8"
LC_COLLATE="de_DE.UTF-8"
LC_MONETARY="de_DE.UTF-8"
LC_MESSAGES="de_DE.UTF-8"
LC_PAPER="de_DE.UTF-8"
LC_NAME="de_DE.UTF-8"
LC_ADDRESS="de_DE.UTF-8"
LC_TELEPHONE="de_DE.UTF-8"
LC_MEASUREMENT="de_DE.UTF-8"
LC_IDENTIFICATION="de_DE.UTF-8"
LC_ALL=
At this point we can modify the language:
$ export LANG=en_UK.UTF-8
Obviously once you will have logged out you will lose all your setting.
Oracle - SQL Plus - See avaible tables in your table space
To see all the table available inside your table space you can use the views available inside sys schema:
SQL> select table_name from user_tables;
Now lets try to have additional information:
SQL>select sys.USER_TABLES.table_name, sys.USER_TAB_COLS.COLUMN_NAME, sys.USER_TAB_COLS.DATA_TYPE
from sys.USER_TABLES
join sys.USER_TAB_COLS on sys.USER_TAB_COLS.TABLE_NAME = sys.USER_TABLES.TABLE_NAME
order by sys.USER_TABLES.table_name asc;
SQL> select table_name from user_tables;
Now lets try to have additional information:
SQL>select sys.USER_TABLES.table_name, sys.USER_TAB_COLS.COLUMN_NAME, sys.USER_TAB_COLS.DATA_TYPE
from sys.USER_TABLES
join sys.USER_TAB_COLS on sys.USER_TAB_COLS.TABLE_NAME = sys.USER_TABLES.TABLE_NAME
order by sys.USER_TABLES.table_name asc;
Saturday, April 28, 2007
Installazione dei fonts Truetype di Microsoft
Molto utile, specialmente se si vogliono visualizzare le pagine web così come le aveva previste chi le ha create (solitamente si sviluppa basandosi sui fonts di Microsoft). E' sufficiente installare il pacchetto msttcorefonts:
$sudo apt-get install msttcorefonts
Per poter utilizzare i font è necessario fare log out e log in, oppure premere Ctrl+Alt+BackSpace per riavviare GDM oppure rigenerare la chace dei font:
$sudo fc-cache -fv
Subscribe to:
Posts (Atom)