Saturday, May 29, 2010

Auto shutdown your PC after completing heavy Downloads !!

This is a small Tutorial which helps us in making a script and running it again and again to Shut down PC after all my downloads complete  !! I am using it on Ubuntu but it should work on other Linux distros too!

#power_off Shell Script

no_cons=`netstat -nt | egrep ESTABLISHED | wc -l`



echo "$no_cons Connections" #Display no. of active Connections 
if [ $no_cons -eq 0 ]
then
echo "Your sys Idle now shutting it down"
sudo shutdown -P 5 # will shutdown PC in 5 minutes if 0 connection
else
echo "Still Downloading...." #displays message if download is on !!
fi


save this script it in your home directory and make it executable by writing :

On Terminal:

chmod +x power_off #power_off is the name of the script here !! 

now we have to make a cronjob so that we can run again and again at specified time intervals(like every 5 minutes or so) !!  

For this we will use cron utility which helps in scheduling jobs. For more on cron have a look at http://kevin.vanzonneveld.net/techblog/article/schedule_tasks_on_linux_using_crontab/

 To make a cron job do the following:

On  terminal:

crontab -e #edit the crontab file 

this will open up an editor (as given in EDITOR environment variable in ~/.bashrc)

now in this file in a new line write 

*/5 * * * *  ~/power_off # This will run our script every 5 minutes 

after you quit your editor if no errors it will show "crontab: installing new crontab" !!

now the only problem we are left to solve is that to run shutdown -P  as a normal user without prompting a  password !! For more on this refer to https://help.ubuntu.com/community/Sudoers#Common Tasks from where the following part is copied:

On Terminal:

sudo visudo

 An editor will open where do the following:


Add some cmnd aliases (under their something like #Cmnd_Alias heading in the file opened) as follows:

Cmnd_Alias SHUTDOWN_CMDS = /sbin/shutdown, /sbin/halt, /sbin/reboot


You also need to add a user specification (at the end of the file after the "%admin ALL = (ALL) ALL" line so it takes effect - see above for details):

 ALL=(ALL) NOPASSWD: SHUTDOWN_CMDS


Obviously you need to replace "" with the username of the user who needs to be able to shutdown the pc without a password. You can use a user alias here as normal.


Now we are done with this save it and quit if no errors it will come out !!

Note: Please close any browser window with a site which updates it automatically otherwise you sys will not shutdown (coz a connection is always)!!

Hope this helps someone! till then bye Jai FOSS !!

PS: Thanks to Mr. Arun Khan who gave me imp. pointers for the script above (on ILUGC ML) !!






Friday, May 14, 2010

FOSS Darshan on Gyan Darshan !!

Today was the first day of a TV show telecast of which can be considered a major breakthrough in itself  !!  Yes, It was the live telecast of the Computer Learning series which is based on FOSS and SchoolOS on Doordarshan's Gyan Darshan  (GD) channel !! I was waiting for it as it was debut of FOSS on TV, was so excited that glued myself to TV from 2:45 (as if the show will start early for me).

Finally it was 3:00 PM I was ready with my lunch and the show started, saw the anchor and then camera was focussed on our Panelists ya our very own, Narendraji (@nsisodiya) and Vivekji (@hiddenharmony)  !! So Narendraji started by telling a bit about FOSS and SchoolOS, and how FOSS licenses lets us and encourages us to share S/W  !! After that it was the time for the first HOW TO of the day !! Sound recording with Sound Recorder , then a bit about Ogg format, then Vivek ji show how to convert a Video to Audio (Ogg) with the help of WinFF(a front-end to FFMpeg) and then after conversion played it for Demo and Guess what it was RMS's voice, It was awesome to hear the Father of Free SW on Indian TV for the first time but then they stopped it rather they had to stop it (It was just a demo na..) !! By this time lines were open so that viewers from all over the country can call and ask their queries. As expected people started calling and asking what is Open Source ?? whether FOSS have viruses and all the normal questions that we are asked, Narendra Ji and Vivek ji gave answers to their queries !! Even the anchor of the show asked some questions like Why FOSS apart from being cost effective ??then Narendraji told about the Full Freedom that FOSS gives to us and it is much important aspect than any other thing !! Then Narendraji showed a demo of Cheese Webcam Booth which can used to make video tutorials !! After that narendraji told two meanings of "Free" as in Freedom and other "Free of Cost" the former one is what it stands for in FOSS (though many FOSS are Free of Cost too)!! In b/w one caller asked about availability of IIS server to which Apache (50% of the websites run on it) and NginX were given as substitutes by Vivek ji!! A caller also asked about Mandriva installation problem from Pen drive to whom Vivekji suggested either to check his drive or get Mandriva in a Fresh CD !! Another caller was Dr. Desai, a Microbiologist hearing whom I was amazed when he said that he already had an Ubuntu CD and Knoppix CD (Nice to see even Doctors interested) , he asked how to install Ubuntu with M$ XP so Vivekji told him about Dual booting and stuff !! then a demo of gtk-recordmydesktop which can used to make video tutorials and screen casting etc.(by Narendra ji) overall it was an awesome show !! I liked it very much and hopefully other viewers too, I wish I could be one of the Panelists someday but its k the show must go on in any case and hopefully will become the most popular show on Gyan Darshan rather on any channel  !! Thanks Narendraji and Vivekji for giving your time!! Narendraji, All the best for the show !! May god bless us with more FOSS culture in our country!

And in the end hats off to Narendraji and his team who convinced NCERT people for SchoolOS and this FOSS show !! Really it is not easy to bring change and  convince people for even good things !!
But this is this will definitely help in spreading FOSS culture in India!!

Would like to hear more from you in comments !! Thanks for reading !! and ya Do Watch........ the
Next show on 20th May Thursday [3 - 4 PM] only on Gyan Darshan (Topic: Chemistry Tools)


til then bye and

JAI FOSS !!