I want to run some scripts when the machine is powered up.
Ubuntu save autostart scripts in /etc/xdg/autostart/. All the files in this folder will run automatically. So I just need to create my custom file in this folder. You can use gnome-session-properties to call a window applicantion.
sudo vim /etc/init.d/rjsupplicant.sh
#!/bin/bash
echo [sudo password] | sudo -S /opt/rjsupplicant/rjsupplicant.sh -d 1 -u [username] -p [rj password] -S 1 &
sudo chmod +x /etc/init.d/rjsupplicant.sh
sudo vim /etc/init.d/inform_ipaddr.sh
#!/bin/bash
echo `ifconfig | grep -i "inet addr"` | mail -s dl_machine_ipaddr mailaddr@qq.com
sudo chmod +x /etc/init.d/inform_ipaddr.sh
Be sure you have installed sendmail tool. More details here.
sudo vim /etc/xdg/autostart/rjsupplicant.desktop
[Desktop Entry]
Type=Application
Name=rjsupplicant
Comment=Log in RuiJie
Exec=/etc/init.d/rjsupplicant.sh
NoDisplay=false
sudo vim /etc/xdg/autostart/inform_ipaddr.desktop
[Desktop Entry]
Type=Application
Name=inform_ipaddr
Comment=Tell about IP address using e-mail
Exec=/etc/init.d/inform_ipaddr.sh
NoDisplay=false
sudo reboot
Done.