Hi Carl,
Rather than pass parameters, use the scripting option with WinSCP. I have over 30 (very simple) interfaces that use WinSCP to SFTP files to various systems using this method to generate scripts on the fly from a Tclproc.
This is how I do it:
# Write script
echo “Writing script file for $systm ($envir $systm)”
set ofh [open $script w]
puts $ofh “# Automatically answer all prompts negatively not to stall”
puts $ofh “# the script on errors”
puts $ofh “option batch on”
puts $ofh “# Disable overwrite confirmations that conflict with the previous”
puts $ofh “option confirm off”
puts $ofh “lcd “D:/interfaces/to oeo/$envir/$systm/inbound/””
puts $ofh “# connect using session”
puts $ofh “open server”
puts $ofh “# Force binary mode transfer”
puts $ofh “option transfer binary”
puts $ofh “# Download file to the local directory”
foreach fname $files {
set fname [file tail $fname]
puts $ofh “put $fname “./to oeo/$envir/$systm/inbound/$fname””
}
puts $ofh “# Disconnect”
puts $ofh “close”
puts $ofh “# Exit WinSCP”
puts $ofh “exit”
close $ofh
# Call WinSCP
echo “Calling WinSCP [clock format [clock scan seconds] -format %d/%m/%Y:%H:%M]”
if {[catch {exec winscp.com /script=$systm.txt} errmsg]} {
echo “There was a problem with the SFTP connection ($errmsg)”
The ‘open server’ command simply opens a connection to a saved WinSCP session called server.
One thing to watch out for is getting winscp.com on the correct path in Cloverleaf.
Regards
Garry