Articles in the Shell Scripting Category

Shell script to enable Remote desktop on ubuntu

To enable remote desktop on ubuntu below is the script
#!/bin/sh
#author : admin@smartproteam.com
#copy rights@smartproteam 2009
#script to enable remote desktop with password

#to enable the remote connection
gconftool-2 -s -t bool /desktop/gnome/remote_access/enabled  true
#to enable password protect

gconftool-2 –type list –list-type string –set /desktop/gnome/remote_access/authentication_methods ‘[vnc]‘
#In my case i have used the password “test1234″ ,if want you …

shell script to query mysql

This script help you understand how to query  mysql using shell script.
its an basic example :

#!/bin/bash
#shell script  to query mysql
db=joomla #db of the table
username=root # you need to provide the username here
pwd=xxxxxx #here you need to enter password
host=localhost #here hostame
mysql -h $host -u $username -p$pwd -D $db -e “select * …

Shell script to add an static ip

Shell script to add static ip .
#!/bin/sh
#shell script to add static ip

killall dhclinet
echo “Adding static ip”
sudo ifconfig eth0 up 192.168.1.2 netmask 255.255.255.0
echo “successfully added eth0″
echo “checking weather the gw is reachable or not ”
while [ -n  "$(ping -c 2 192.168.16.1 | grep 100%)" ]
do
echo “gateway not reachable try it agian”
exit
done
echo  …

Shell Script for memory alert

Shell script which tell about low memory status message with xwindow dailog box.
#!/bin/sh
#
#author : admin@smartproteam.com
#copy rights@smartproteam 2009
#script to low ram alert
tolmem=$(free -m| grep Mem | awk ‘{print $4}’)
expmem=300
if [ $tolmem -lt $expmem ]
then
xmessage “Physical mem is low”
fi
output

Shell script to ping multiple hosts

Script to ping multiple host .
first step follows

create a .txt file with hostnames
for example
ping.txt
hostname1 or ip
hostname2 or ip
copy below script into a file and name it as hostping.sh
#!/bin/bash
#
#author : admin@smartproteam.com
#copy rights@smartproteam 2009
#script to ping multiple hosts
#for loop
for i in cat `cat ~/ping.txt`
do
fping $i | grep unreachable
done
Now change the …