NAVEEN PRAKASH
NAVEEN PRAKASH

Reputation: 130

cp command from tcl script

Hi I am writing a tcl script to automate the task in linux. In that I want to copy files. The command is cp -r source destination. I have tried using puts [cp -rf source destination]. But I am getting error saying invalid command cp. How will I write it in tcl script.

Upvotes: 1

Views: 3714

Answers (1)

Donal Fellows
Donal Fellows

Reputation: 137567

To run an external program from your script, you should use the exec command:

puts [exec cp -r $source $destination]

However, for the specific case of copying a directory from one place to another you can use the built-in file copy command (which works with directories as well as files):

file copy $source $destination

Upvotes: 4

Related Questions