Posted by: Administrator
on July 08, 2004 07:51 PM
Don't think that you're NOT or CAN'T be a sysadmin without learning Perl. I know enough perl to be able to read other scripts written in perl, and do some basic things in perl, but I prefer to do my sysadmin scripts in Expect or TCL/TK. (Expect is actually an extention to TCL.)
In TCL you don't have to worry about $ % @. All variables use a $. All these different notations for variables is just confusing. To show that TCL is simpler look at the hash example. To do the same thing in tcl type:
See the TCL example is 20% shorter than the perl example. The line is almost self explanitory, You've set an array, how much simpler could that be? You will find your TCL scripts are usually 20% - 50% shorter in TCL, which means less typing, less debugging, and quicker script creation. NOTICE also that TCL commands don't have a ';' at the end of each line, as TCL is smart enough to be able to figure out where the line ends without one.
I've found that for my day to day tasks TCL works better. It's not as cryptic as perl, and it's easier for me. The two things I like best about TCL is (1) The Expect extention, (2) tclsh. Tclsh is a stripped down shell that you can type commands in for example:
rm@linuxsystem:~$ tclsh % % array set usershell {jimi '/bin/bash' eric '/bin/tcsh' eddie '/bin/csh' billy '/bin/zsh'} % puts $usershell(jimi) '/bin/bash'
This allows me to evaluate or test some subroutines in a shell environment before sticking them in a script. My advice is to find what works for you. You've got Perl, TCL, Python, Ruby, Bash, CSH, and probably one or two I forgot to mention.
you're not a sysadmin if...
Posted by: Administrator on July 08, 2004 07:51 PMIn TCL you don't have to worry about $ % @. All variables use a $. All these different notations for variables is just confusing. To show that TCL is simpler look at the hash example. To do the same thing in tcl type:
array set usershell {jimi<nobr> <wbr></nobr>/bin/bash eric<nobr> <wbr></nobr>/bin/tcsh eddie<nobr> <wbr></nobr>/bin/csh billy<nobr> <wbr></nobr>/bin/zsh}
To see what shell eric has just use:
puts $usershell(eric).
See the TCL example is 20% shorter than the perl example. The line is almost self explanitory, You've set an array, how much simpler could that be? You will find your TCL scripts are usually 20% - 50% shorter in TCL, which means less typing, less debugging, and quicker script creation. NOTICE also that TCL commands don't have a ';' at the end of each line, as TCL is smart enough to be able to figure out where the line ends without one.
I've found that for my day to day tasks TCL works better. It's not as cryptic as perl, and it's easier for me. The two things I like best about TCL is (1) The Expect extention, (2) tclsh. Tclsh is a stripped down shell that you can type commands in for example:
rm@linuxsystem:~$ tclsh
% % array set usershell {jimi '/bin/bash' eric '/bin/tcsh' eddie '/bin/csh' billy '/bin/zsh'}
% puts $usershell(jimi)
'/bin/bash'
This allows me to evaluate or test some subroutines in a shell environment before sticking them in a script. My advice is to find what works for you. You've got Perl, TCL, Python, Ruby, Bash, CSH, and probably one or two I forgot to mention.
#