๐Ÿ“œ
B.TECH III YEAR โ€ข II SEMESTER โ€ข R22

Scripting Languages - Lab Manual

Scripting Languages Laboratory โ€ข Program 16 Solution

๐Ÿ“˜ R22 Regulation ๐ŸŽ“ III Year ๐Ÿ“š II Semester ๐Ÿ“œ Scripting Languages ๐Ÿ’Ž Ruby โ€ข TCL โ€ข Perl ๐Ÿงช Lab Program
Aim of Program 16

Write a TCL script to Copy a file and translate to native format.

โ† All Programs
Solution

Aim:

☛   Write a TCL script to Copy a file and translate to native format.

Solution :

PROGRAM: (copy_file.tcl)

 
set sourceFile "input.txt"
set destFile   "output.txt"

# Open source file for reading
set in [open $sourceFile "r"]

# Open destination file for writing in native format
set out [open $destFile "w"]
fconfigure $out -translation native

# Copy content line by line
while {[gets $in line] >= 0} {
    puts $out $line
}

# Close files
close $in
close $out

puts "File copied and translated to native format."



OUTPUT:

 
File copied and translated to native format.



โ† Back to Scripting Languages Lab Programs ๐Ÿ“š All Lab Manuals