1.What are the different ways to initialize a variable. How
to differentiate global and local variables, explain it
through a simple tcl program.
2.Create a list of week days and print the first and last
character of each day using foreach command
3.Can you write a small program to verify the given input is
file or directory.Before checking, just ensure that the
file/dir exists or not in the given path. If the given
input is a file, findout the size and verify that the file
has all read ,write and execute permission.
Answer Posted / amirtha
Ans for 3rd Question:
input is filename
if {file exists filename} {
set dir [ file isdirectory filename]
if {$dir == 1} { puts "filename is directory"
} else {
set fil [ file isfile filename]
set size [file size filename ]
puts "filename is file of size
file readable filename ;#to check file is readable by current user
file owned filename ;#to check file is owned by current user
file writable filename ;#to check file is writable by current user
}
Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers