My 2 paisas

Posts Tagged ‘script

I have to use VNC many times for my work. Everytime to invoke vncviewer, I had to press -F2 and then type “vncviewer”. I didnt want to do this and hence I thought I will write a simple shell script which I can use to run whenever I needed vncviewer. Hence I wrote following two lines in a shell script.


This I saved on my desktop and used to double click it whenever I needed to run it. However even this used to ask me if I wanted to run it or display it. Also the script had a default icon which I didnt want and wanted it to have the icon of vnc. Also I didnt like it to occupy my desktop area and wanted to keep it on my panel. Hence i searched on google for answers. i found the following mail which gave me a clear idea of how to do it.

You can create your own icons by creating a textfile and giving it a .desktop
extension. That’s all an icon is. Go to /usr/share/applications and have a look.
Anyone of those files can be dragged into you ~/Desktop folder if you use that for
desktop icons or else directly onto your desktop.

The format of the .desktop file is fairly simple to follow I have made them for
url as well as script icons and keep them in /usr/local/share/applications. Once
you have created the file the “icon” can be used like any other icon, e.g. adding
to Quicklaunch. Use anything for an icon. Here is what one of mine looks like.

[root@localhost ~]# cat /usr/local/share/vncviewer.desktop
[Desktop Entry]
Comment = runs vncviewer script

Hence now I could drag this icon on my panel and launch vncviewer in just one click.

With the help of Abhas Bhaiyya, I could write this shell script which checks if an ipaddress can be pinged.


if [ `ping -c1 >/dev/null; echo $?` -eq 1 ]
echo “not able to ping”

/dev/null is used here so that the output of the ping command is not compared with 1.
$? gives out the return code of the command.

‘!$’ is the right answer.

For example: $vim
$chmod +x !$

So what is happening above is
first vim opens a file.
then after you have written a perl script, you would like to make it executable. There is no need for you to specify the file name again. You can just use !$.
In the third command again to execute the file, there is no need to mention the file name again. You just use !$ again.

Links that I liked to save

Blog Stats

  • 43,378 hits