venerdì 17 febbraio 2012

Comandi vi

Comandi base vi

Comandi avanzati vi

UBUNTU - Add an entry to fstab (fat32 rw partition)

Quite simple task, anyway:
First of all give a look to your mounted filesystems, ok I want automatically at boot to mount the fat32 partition /dev/sda7 in the /media/DATA mount point.

fem@rodizio:~$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda5 206626768 33899652 162231052 18% /
none 1854844 304 1854540 1% /dev
none 1862524 284 1862240 1% /dev/shm
none 1862524 356 1862168 1% /var/run
none 1862524 0 1862524 0% /var/lock
none 1862524 0 1862524 0% /lib/init/rw
/dev/sda7 102348272 15804064 86544208 16% /media/DATA

create a mount point (in this case /media/DATA/ )

fem@rodizio:~$ sudo mkdir /media/DATA

generate the uuid number for the partition /dev/sda7

fem@rodizio:~$ sudo ls -l /dev/disk/by-uuid
total 0
lrwxrwxrwx 1 root root 10 2012-02-17 09:46 429CA4729CA461E1 -> ../../sda3
lrwxrwxrwx 1 root root 10 2012-02-17 09:46 7830198a-6c13-4b13-99ac-c6fe1eb15e80 -> ../../sda5
lrwxrwxrwx 1 root root 10 2012-02-17 09:46 9cf45b4e-2b01-4e70-806b-be488e4ebe59 -> ../../sda6
lrwxrwxrwx 1 root root 10 2012-02-17 09:46 C2C0A2A6C0A29FE1 -> ../../sda2
lrwxrwxrwx 1 root root 10 2012-02-17 09:46 C8D6A22CD6A21AA8 -> ../../sda1
lrwxrwxrwx 1 root root 10 2012-02-17 09:46 E9ED-DDA3 -> ../../sda7

So the uuid for the partition /dev/sda7 is E9ED-DDA3
Then edit /etc/fstab with vi or another editor.

fem@rodizio:~$ sudo vi /etc/fstab

and add this line:

UUID=E9ED-DDA3 /media/DATA/ vfat auto,umask=000 0 0

Note that "auto,umask=000 0 0" let you gain read/write permission on fat32 filesystem for the normal user.
Then reboot or give this command

fem@rodizio:~$ sudo mount -a

that's all

giovedì 9 febbraio 2012

iPhone 4 - How to pass AT Commands (and make a voice call)

My goal is to send a call via iPhone shell using AT commands.

I installed minicom from Cydia (but I think you could use other programs to "speak" with the serial interface of the phone).
I refer to this page
for more infos.
I found problems on serial port setup, i tryed these interfaces with no luck :

/dev/debug
/dev/dlci.spi-baseband.extra_13

I had a look in /dev folder and I found these interfaces:

iPhone4:/dev root# ls /dev
aes_0 io8logmt tty.highland-park
bpf0 klog tty.iap
bpf1 mux.spi-baseband tty.umts
bpf2 null ttyp0
bpf3 pf ttyp1
btreset ptmx ttyp2
btwake ptyp0 ttyp3
console ptyp1 ttyp4
cu.bluetooth ptyp2 ttyp5
cu.debug ptyp3 ttyp6
cu.gas-gauge ptyp4 ttyp7
cu.gps ptyp5 ttyp8
cu.highland-park ptyp6 ttyp9
cu.iap ptyp7 ttypa
cu.umts ptyp8 ttypb
disk0 ptyp9 ttypc
disk0s1 ptypa ttypd
disk0s2 ptypb ttype
disk0s2s1 ptypc ttypf
dlci.spi-baseband.call ptypd ttys000
dlci.spi-baseband.chatty ptype uart.bluetooth
dlci.spi-baseband.cl1 ptypf uart.debug
dlci.spi-baseband.extra_0 random uart.gas-gauge
dlci.spi-baseband.iq rdisk0 uart.gps
dlci.spi-baseband.low rdisk0s1 uart.highland-park
dlci.spi-baseband.pdp_0 rdisk0s2 uart.iap
dlci.spi-baseband.pdp_1 rdisk0s2s1 uart.umts
dlci.spi-baseband.pdp_2 sha1_0 urandom
dlci.spi-baseband.pdp_3 tty vn0
dlci.spi-baseband.pdp_ctl tty.bluetooth vn1
dlci.spi-baseband.reg tty.debug zero
dlci.spi-baseband.sms tty.gas-gauge
io8log tty.gps


I found /dev/dlci.spi-baseband.extra_0 working fine but honestly I cannot ensure it work for you too.

You have to setup minicom to work properly,

iPhone4:/dev root# minicom -s

then chose "Serial port setup" and press A and edit the line of the serial device (for me was that):

A - Serial Device : /dev/dlci.spi-baseband.extra_0

Type esc and "Save setup as dfl", then exit and type

iPhone4:/dev root# minicom -w

to connect to the phone.
Then type AT, if you receive an "OK" answer all is fine otherwise check "serial port setup" setting.
To make a call to the 3931111111 number simply type:

atd3931111111;

and to hang call

ath

To get iccid number (sim serial number)
type:

at+ccid

To get imei number.

at+cgsn


That's all.

mercoledì 8 febbraio 2012

iPhone 4 - How to automatically launch a script every fixed time. (Plist)

The goal is: launch my own script on my iphone every 300 seconds (5 minutes) for example.

Since the iPhone has no working cron deamon since 3.0 you can achieve it with the launchd deamon.
Launchd on Apple manpages
You have to have a running script, I suggest you to test it on iphone shell before going forward.
For example the script to launch could be this:

/var/root/scripts/hello


You have to create a .plist file in /System/Library/LaunchDaemons/ , I called it org.me.hello.plist
The hello.plist should be like this:

 <?xml version="1.0" encoding="UTF-8"?>  
 <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">  
 <plist version="1.0">  
 <dict>  
 <key>Label</key>  
 <string>org.me.hello</string>  
 <key>ProgramArguments</key>  
 <array>  
 <string>/var/root/scripts/hello</string>  
 </array>  
 <key>RunAtLoad</key>  
 <true/>  
 <key>StartInterval</key>  
 <integer>300</integer>  
 </dict>  
 </plist>  

After that, you have to tell the system to load this new service hello.plist


iPhone4:~ root# launchctl load /System/Library/LaunchDaemons/org.me.hello.plist

Now your script should be launched automatically every 300 seconds (5 minutes) by the iPhone.

That's all.

mercoledì 1 febbraio 2012

Resizing (a lot of) images with a command.

I have to resize few pictures for a website, if you use Ubuntu you can use this command line tool called "mogrify" included in the "imagemagick" package.

To install it:

fem@rodizio:~$ sudo apt-get install imagemagick


Then, resize...

fem@rodizio:~$ cd /path/to/pictures/
fem@rodizio:~$ mogrify -resize 450x338 -format jpg *.jpg


Here I resize all jpg images I have in the folder to the 450x338 resolution, but you can change parameters how you prefer.


Note that this command will overwrite the previous pictures.
That's all