How to find if a file exists in expect script
expect
Solution
Since expect is an extension of Tcl, all Tcl commands are available to use:
if {[file exists backup.txt]} {
send "sed -i -e 's/$oldport/$newport/' backup.txt\r"
expect "$ "
}
Problem
I have a statement inside my expect script like this ``` send "sed -i -e 's/$oldport/$newport/' backup.txt\r" expect "$ " ``` However I wish to first check whether the file backup.txt exist and if it does, then edit it. How do I acheive this? Thanks