Saturday, April 24, 2010

script to copy file to remote server (Using scp)

I always want to copy files to my athena account, which is the server in our lab where i have an account.So i wrote this script , which helps me not to write a long line command always.

#!/bin/bash
#
#Author: IRFAN NASEEF 
#
#

if [ $# -lt 1 ]
then 
  echo "Error:Specify atleast a file"
  exit 1 ;
fi

echo "Specify Destination folder"
read dest;

for file in $@
do
  if [ -f $file ]
  then
    echo "Copying file $file to $dest"
    scp $file b070147cs@192.168.40.99:$dest
    if [ $? -eq 0 ]
    then
      echo "Successfull"
    else
      echo "Error :copying" 
    fi
  else
    echo "Error: $file doesnot exist"
    exit 2 ;
  fi
done 

exit 0;
#############################################

And if you have done as per this post(see here) , you can save typing passwords too .

Saturday, April 17, 2010

PHP script for getting tweet updates

Here is the php script to get updates from a twitter account.

   $uname = "YourUserName";
   $url = "http://twitter.com/statuses/user_timeline/$uname.rss";
   $rss = @file_get_contents($url);

  if($rss)
  {
          $xml = @simplexml_load_string($rss);
          if($xml !== false)
           {
                 foreach($xml->channel->item as $tweet)
                  {
                       echo $tweet->pubDate."\n";
                       echo substr($tweet->description,10)."\n";
                   }
            }
           else
             {
                   echo "Error: RSS file not valid!";
             }
       }
       else
      {
          echo "Error: RSS file not found, Invalid username";
      }
?>



Thursday, April 15, 2010

Downloading youtube videos

There are lot of ways you can download youtube videos.I will mention a few online downloaders..
Different methods are here:
  1.   Replace youtube in the URL by voobys
     If the url of the video is http://www.youtube.com/watch?v=4k2_HHrk8Y8 ,change it to  http://www.voobys.com/watch?v=4k2_HHrk8Y8 , You can download the video from this link.

   2) Add "kiss" to the youtube URL
         So change the above url as  http://kissyoutube.com/watch?v=4k2_HHrk8Y8
 
   3) Add ok to the URL
           Change url as http://okyoutube.com/watch?v=4k2_HHrk8Y8

  4) Some other webpages where you can download youtube videos:
  5) For those who prefer command line terminal , use Youtube-dl package . You can then  download the video by typing   youtube-dl 
But remember downloading vids is forbidden by the Terms of Service of youtube and in some cases illegal.You can watch them on YouTube and you can, providing the video owner lets you, "embed" them to other sites using the code beside the video you want to show off elsewhere.  And you can use the email function to send them to people who you want to show it to.
All that is done on YouTube, directly on the video's page itself.  :)

Monday, April 12, 2010

Searching mails in Gmail

Recently i was searching for a method to get all my unread mails from my inbox in gmail. I felt it very difficult to search for it manually .So as usual i googled for a solution .I was really surprised to see the power of gmail search mail option. You can simply give a search for
is:unread
.All the unread mails will be listed..wow..nice one isnt ?

See below options too .

Keyword what it will do ?

from:abc --- get all mails from abc
to:abc --- get all mails send to abc

is:read --- get all read mails
is:unread --- get all unread mails
is:starred --- all starred mails

in:inbox --- mails in inbox
in:trash --- mails in trash
in:spam --- mails marked as spam

Many options are there.. Get the entire list from See here

Sunday, April 04, 2010

tweeting from the BASH terminal

i feel this an awesome script..tweet from command line terminal in linux..
script is as follows:

#!/bin/bash

username="yourUserName" ;
password="yourPassword";

URL="http://twitter.com/statuses/update.xml" ;

if [ $(echo "$1" | wc -c ) -gt 140 ]
then
echo "Whoo: Its more than 140 characters"
exit 0;
fi

result=$(curl -u $username:$password -d status="$1" $URL) ;

exit 0 ;

save this in some file name "tweet" and make it executable ( chmod +x tweet )
And for simplicty add an alias ..
Now tweet from terminal using the command
tweet "tweeting from the command line"

Monday, March 22, 2010

Add file to VLC playlist by right clicking

I found a simple nautilus script which is very usefull for those who usually plays something in VLC. Script to add a file to VLC playlist by simple right clicking on the file .

What to do ?


cd ~/.gnome2/nautilus-scripts

touch "Add to VLC Playlist"

then copy the following to the file "Add to Playlist"

Pre-requisite: Install zenity from your package manager


#!/bin/bash

## Ny Narendra Sisodiya, for SchoolOS
## narendra.sisodiya@gmail.com
## modified by: IRFAN NASEEF P
##             irfan@nitc.ac.in

checkFileType()
{
  file $1 | grep -i "audio" || file $1 | grep -i "video" || file $1 | grep -i "ogv" || file $1 | grep -i "mpeg"
  RES=$?
  if [ $RES -eq 0 ]
  then
      return 0
  else
      zenity --error --title "VLC says: " --text "Error: $FILENAME is not an audio/video file"
      return 1
 
   
   fi
}

IFS=$'\n'
for FILENAME in $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
do
  checkFileType $FILENAME

  if [ $? -eq 0 ]
  then
    vlc --started-from-file --one-instance-when-started-from-file --playlist-enqueue "$FILENAME"
    
 fi
done

exit 0

################

Then save ..

Now you can see a 'Scripts' option when you right click , and a 'Add to VLC Playlist' in it. Now you can directly add files to playlist by simply right clicking .