Main Menu

friends

Latest articles

Hello World in perl
18/11/2009 | mad mad mod

This article describes how to write and execute a "Hello World" perl script on Linux (Fedora).  1. the prerequisitesa text editor of your choice (e.g. vi)the perl interpreter
make sure you have in [ ... ]


the easy way to kill processes
29/12/2009 | mad mad mod

Use pkill to kill processes based on their name. For example to terminate all instances of mplayer:


# pkill mplayer
    


Other Articles
Facebook MySpace Twitter Digg Delicious Stumbleupon Google Bookmarks 

Designed by:
SiteGround web hosting Joomla Templates
hello world in tcl - radically simple E-mail
programming

This article describes how to write and execute a "Hello World" tclsh script on Linux (Fedora).

 

1. the prerequisites

  • a text editor of your choice (e.g. vi)
  • tclsh - Simple shell containing Tcl interpreter

make sure you have installed the bash shell:

# [root@fedora12 Desktop]# rpm -q tcl
tcl-8.5.7-4.fc12.i686

 

If it is not installed yet, you can install it with yum (you need to be root to do that):

# yum install tcl

 

 

2. write the code


open an empty file with a text editor (e.g. vi):


# vi helloworld.sh



now write the following lines into it:


#!/bin/sh
# the next line restarts using tclsh \
exec tclsh "$0" "$@"

puts "Hello World!"



save the file and exit vi with ":wq + enter"

 

explanation


#!/bin/sh

This tells the system to use the /bin/sh interpreter to execute the script. You can find out the full path of your sh interpreter by entering the following command:


# which sh

/bin/sh




# the next line restarts using tclsh \

exec tclsh "$0" "$@"

 

from the man page:

"The exec statement cause the  shell  to  stop processing  and  instead  to  start  up  tclsh  to reprocess the entire script.  When tclsh starts up, it treats all three lines  as  comments, since the backslash at the end of the second line causes the third line to be treated as part of the comment on the second line."

 


puts "Hello World!"

{/chilicode}

 

prints the string "Hello World!"

 


3. make the script executable



# chmod u+x helloworld.sh




4. run the program


you can now execute the script program with:


# ./helloworld.sh

Hello World!

Comments (0)
Write comment
Your Contact Details:
Comment:
[b] [i] [u] [url] [quote] [code] [img]   
:D:angry::angry-red::evil::idea::love::x:no-comments::ooo::pirate::?::(
:sleep::););)):0
Security
Please input the anti-spam code that you can read in the image.

!joomlacomment 4.0 Copyright (C) 2009 Compojoom.com . All rights reserved."

 
mad mad mod, Powered by Joomla! and designed by SiteGround web hosting