Tuesday, January 10, 2012

All You Can Expect In A TCL Interview

TCL is an easy to learn language that has a number of features and it can be used for a wide range of applications. The most common one is the automation. It can be used with expect to create interactive applications, where we send the commands to the command line, expect an output and evaluate the output using TCL via scripts.

Having a base in any programming language will help you learn TCL quickly. But this is not mandatory because most of the commands in TCL are simple and self explanatory. This post is meant for aspiring engineers who wish to work in a TCL automation project. This post would be useful especially for people who have started attending interviews and trying hard to get into this field.

To be honest, there are very few people who know TCL here in this industry. This is because the developers who are good at programming go for usual stuff like C, C++, Java etc. Testers are mostly manual testers who always develop a fear for programming. The concept of automation is something that bothers the testers as they consider it is as a very difficult task. As a result of all these attitudes, we have very less people for TCL automation but there are quite a lot of opportunities.

A little bit of practice is more than enough to get into a TCL automation project. Most of the requirements would say, “Should be good at TCL/TK. Knowledge of networking is preferred”. So going through the basics of networking would definitely help. One month before you start attending interviews, start taking notes of OSI layers from the net or from good networking books. This would be useful for you to brush up the concepts on the previous day of the interview. Have a clear cut idea about the layers, what they do and the protocols they use. Difference between TCP and UDP is a standard question in any networking interview. A detailed and crispy answer to this is available here:

http://networkinterviewquestionsandanswers.blogspot.in/2012/08/difference-between-tcp-and-udp-best.html

Since it involves testing, some of the testing questions can be asked. Eg:

1. Difference between black box and white box testing.
2. Who does white box testing(Developers or testers)?
3. Is unit testing white box or black box?
4. Difference between regression and re-testing
5. Why is testing essential for a project? What is the significance of testing?
6. Name a critical bug that you had raised in your project that was appreciated?

The answers to the above questions are available here

http://tclinterviewquestions.blogspot.com/2011/12/answers-to-questions.html

Now we will come to the important part where most of the questions will be asked i.e TCL. If the interviewer is not a TCL person (though it does not happen mostly) the expected questions would be:

1. Write down all the list commands and explain what they do?
2. Write down all the string commands and explain what they do?
3. Write a regexp to match an ip address.(very common question)
4. Write the syntax of “for” and “if” loops?

If the interviewer is a TCL person, the questions might be:

1. Write a regexp to match an ip address?
2. How do you pick each part of the ip address and place them in separate variables?
3. What do these signify (. * ? +) in regexp?
4. What is command substitution, variable substitution and backslash substitution?(very common question)
5. Difference between using curly braces and quotes in TCL?
6. Convert a string into a list.
7. Convert a list into a string.
8. Write a program to reverse a string.
9. Find the length of a string without using “string length” command.
10. What are your strong areas in TCL?(string, list regexp etc..)
11. What is upvar and uplevel in TCL?
12. Write a program to connect to a system and to login using EXPECT script?

Answers to some of these questions are available here. Planning to post the remaining as well.

http://tclinterviewquestions.blogspot.in/2012/01/answers-to-tcl-interview-questions.html

Hope this post was useful for aspiring engineers. All the best everyone!
If you require answer for any of these questions, feel free to leave a comment.

Programs
1. Find the length of a string without using string length command


set s "Arun"
set len 0
foreach item [split $s ""] {incr len}
puts "The length of the string is : $len"

In the above program, a string is converted to a list [split $s ""] and then for each letter in the word (element in the list) the variable len is incremented until it reaches the end. Thus len contains the string length.



List Command:
List command returns a list comprising of all the arguments specified.

Syntax:
list arg1 arg2....

Example:
list a b "c d e  " "   f { g h }"
returns : a b {c d e } {  f {gh} }
======================================================================
Lappend Command:
lappend command treats var1 as a list and appends all the values to the list with a space between elements. If var1 does not exist then a new list called var1 is created with the elements value1, value2, value3 etc.

Syntax:
lappend var1 value1 value2 value3...
set var1 1
1
lappend var1 2
1 2
lappend var1 3 4 5
1 2 3 4 5
======================================================================
 
Easiest Example To Explain Upvar Command

Usage:

Used when we have to change the value of a global variable from inside a procedure’s scope

Example
proc example {one two} {
upvar $one local1
upvar $two local2

set local1 Kavitha
set local2 Anbarasu

}

set glob1 David
set glob2 Beckam

puts $glob1
puts $glob2\n

example glob1 glob2

puts $glob1
puts $glob2

Output
David
Beckam

Kavitha
Anbarasu

In the above example we are able to change the value of two global variables glob1 and glob2 from within a procedure

======================================================================
regsub Command Usage


Regsub Usage

Replaces a value with a given value

Syntax:
regsub “”  $string “


Example:

set string "My name is Kavitha"

regsub "Kavitha" $string "Mythri" name2
puts "$name2"

Output

My name is Mythri

======================================================================

:? Command Usage

Usage:

?: is used in sub patterns in a regexp
When ever you don’t want a particular subpattern to be included as a sub-pattern use “?:” in front of the sub-pattern

Example:

set string "Projects: Brocade Cisco Fujitsu"

regexp "Projects: (Brocade|Cisco) (?:Fujitsu|Juniper|Cisco) (Fujitsu|Juniper)" $string sub1 sub2 sub3

puts "$sub1\n$sub2\n$sub3\n"

In the above example, the output will be

Projects: Brocade Cisco Fujitsu
Brocade
Fujitsu

The pattern “Cisco” does not come under sub pattern as “?:” is given

The output without ?: would be


Projects: Brocade Cisco Fujitsu
Brocade
Cisco

======================================================================

Different String Commands In TCL

set one “np”
set two “gqaxbnp”
puts [string compare $one $two]
puts [string length $one]
puts [string index $two 2]
puts [string first $one $two]
puts [string last $one $two]

o/p:
1
2
a
5
5

To Know More About What Happens in a TCL Network Testing Project and the Issues Faced And Their Resolutions Refer The Below url

http://tclautomationnetworktesting.blogspot.in/



==================================================
Though it is not relevant, just an addition information on a different subject :)
To know about taking care of babies click here

http://kavitha-allaboutbabies.blogspot.in

==================================================

9 comments:

  1. Where are the answers for TCL part ?? Only testing part is coered which is very "good". But there are no answers for the TCL questions you have mentioned in your blog.
    Clicking on the mentioned link, redirect to this page

    If possible please mentioned all the answers ASAP.

    Thanks,
    Kushal Maheshwari

    ReplyDelete
  2. Hi Buddy,

    Gratitude for putting up this prolific article! You truly make everything a
    cake walk. Genuinely good stuff, saving time and energy.

    First and foremost I'd like to say I'm very excited to be a part of
    the Python world which is truly beautiful and limitless (I'm about to find out
    that).

    My goal is to make a simple script that would copy all the settings in Windows
    related to the mouse (windows sensitivity, DPI, pointer precision etc.) from my
    computer in home and with that information paste all that information to my
    Windows at work.

    I'm trying to play games competitively and I'm noticing that once I get used to
    the sensitivity at work for 8 hours it takes an uncomfortable while and deaths
    in games to get into the sensitivity here.

    I wasn't able to find nothing related to such information gathering/setting
    afterwards.

    I'm not necessarily looking for a complete script(even though I could use it as
    a guidance), but rather a specific module or tutorial that would bump me into
    creating such script myself.

    Thank you very much and will look for more postings from you.

    Regards,
    Morgan lee

    ReplyDelete
  3. Hi Your Blog is very nice!!

    Get All Top Interview Questions and answers PHP, Magento, laravel,Java, Dot Net, Database, Sql, Mysql, Oracle, Angularjs, Vue Js, Express js, React Js,
    Hadoop, Apache spark, Apache Scala, Tensorflow.

    Mysql Interview Questions for Experienced
    php interview questions for freshers
    php interview questions for experienced
    python interview questions for freshers
    tally interview questions and answers

    ReplyDelete
  4. A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
    website: geeksforgeeks.org

    ReplyDelete
  5. A Computer Science portal for geeks. It contains well written, well thought and well
    explained computer science and programming articles, quizzes and practice/competitive
    programming/company interview Questions.
    website: geeksforgeeks.org

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. tcl scripting for vlsi
    TCL Scripting and Its Career Choices in Bangalore TCL scripting for VLSI design requires a lot of circuit knowledge.

    ReplyDelete
  8. This comment has been removed by a blog administrator.

    ReplyDelete