Description
The FileTransfer object provides methods for performing file transfers initiated by scripts.
Syntax
Remarks
SecureCRT's
FileTransfer object is accessed through
the top-level object’s FileTransfer
property.
FileTransfer Object Properties and Methods
|
||
|
||
|
||
|
|
Description
Returns path for session download folder.
Remarks
DownloadFolder is a read-only property that returns the path for the current session's download folder. Note, files downloaded with either Xmodem or Zmodem are always placed in the session's download folder. Scripts can use this property to determine the location of the downloaded files.
VBScript
Syntax
crt.FileTransfer.DownloadFolder
Example
MsgBox "Download completed to: " & vblf & crt.FileTransfer.DownloadFolder
Python
Syntax
crt.FileTransfer.DownloadFolder
Example
crt.Dialog.MessageBox("Download completed to: \n" + crt.FileTransfer.DownloadFolder)
Description
Specifies ASCII or binary mode for Zmodem Zmodem is a file transfer protocol that touts speed and reliability. In this terminal emulation application, it provides a mechanism for secure file transfers as long as the remote machine has Zmodem support installed. uploads.
Remarks
ZmodemUploadAscii specifies whether files uploaded using Zmodem will be in ASCII or binary format. When ZmodemUploadAscii is set to "true", uploads will be made in ASCII. After you have run a script that sets the ZmodemUploadAscii option to true, that setting will be saved as a session A session is a set of options that are assigned to a connection to a remote machine. These settings and options are saved under a session name and allow the user to have different preferences for different hosts. option until it is changed back either by running another script that resets it to false or by changing the option in the Select Files to Send using Zmodem dialog. If no argument is specified for this property, the current value is returned.
Note
For this option to work properly, the installation of Zmodem on the remote machine must be able to convert ASCII to use the local convention for line termination.
VBScript
Syntax
crt.FileTransfer.ZmodemUploadAscii = [True | False]
Example
#$language = "VBScript"
#$interface = "1.0"
Option explicit
Dim szPrompt
szPrompt = "->"
crt.screen.synchronous = True
' Zmodem ASCII uploads
crt.FileTransfer.AddToZmodemUploadList "c:\temp\File1.txt"
crt.FileTransfer.AddToZmodemUploadList "c:\temp\File2.txt"
crt.FileTransfer.AddToZmodemUploadList "c:\temp\anotherFile.txt"
' Let CRT know that we want these files to be transferred as ASCII
crt.FileTransfer.ZmodemUploadAscii = True
' Start the Zmodem upload
crt.Screen.Send " rz A Zmodem command that initiates a Zmodem receive operation. The rz command can be run from the command line on a remote machine to instruct the sender that the remote machine is ready to receive data. See also: sz " & vbCR
' Wait for transfer to complete
crt.Screen.WaitForString szPrompt
' Reset ASCII flag
crt.FileTransfer.ZmodemUploadAscii = False
Python
Syntax
crt.FileTransfer.ZmodemUploadAscii = [True | False]
Example
#$language = "Python"
#$interface = "1.0"
crt.Screen.Synchronous = True
# Zmodem ASCII uploads
crt.FileTransfer.AddToZmodemUploadList("c:\\temp\\File1.txt")
crt.FileTransfer.AddToZmodemUploadList("c:\\temp\\File2.txt")
crt.FileTransfer.AddToZmodemUploadList("c:\\temp\\anotherFile.txt")
# Let CRT know that we want these files to be transferred as ASCII
crt.FileTransfer.ZmodemUploadAscii = True
# Start the Zmodem upload
crt.Screen.Send("rz\n")
# Wait for transfer to complete
crt.Screen.WaitForString("->")
# Reset ASCII flag
crt.FileTransfer.ZmodemUploadAscii = False
Description
Places file on Zmodem upload list.
Remarks
AddToZmodemUploadList places the specified file on a list of files that will be uploaded during the next Zmodem upload. Once one or more files have been added to the upload list, a Zmodem upload can be initiated by the script sending the appropriate command to the remote system.
Errors:
If the path provided to AddToZmodemUploadList is not a valid file, a script error is generated and the following message is displayed:
"FileTransfer.AddToZmodemUploadList: <filepath> does not exist."
VBScript
Syntax
crt.FileTransfer.AddToZmodemUploadList filepath
Example
crt.FileTransfer.AddToZmodemUploadList "c:\temp\File1.txt"
crt.FileTransfer.AddToZmodemUploadList "c:\temp\File2.txt"
' Start the upload of the two files...
crt.Screen.Send "rz" & vbCR
Python
Syntax
crt.FileTransfer.AddToZmodemUploadList(filepath)
Example
crt.FileTransfer.AddToZmodemUploadList("c:\\temp\\File1.txt")
crt.FileTransfer.AddToZmodemUploadList("c:\\temp\\File2.txt")
# Start the upload of the two files...
crt.Screen.Send("rz\n")
Description
Sends specified file.
Remarks
SendXmodem sends the specified file using the Xmodem protocol. The full path to the file must be specified. Note, the appropriate Xmodem receive command should be sent or initiated on the remote system before executing SendXmodem for the transfer to begin properly.
Errors:
1. If the SendXmodem method is executed while not connected the following script error is generated:
"FileTransfer.SendXmodem: not connected"
2. If the path provided to SendXmodem is not a valid file then a script error is generated and the following message is displayed:
"FileTransfer.SendXmodem: <filepath> does not exist."
VBScript
Syntax
crt.FileTransfer.SendXmodem filepath
Example
' upload C:\temp\myFile.txt using Xmodem
crt.Screen.Send "rx myFile.txt" & vbCR
crt.Screen.WaitForString "ready to receive"
crt.FileTransfer.SendXmodem "C:\temp\myFile.txt"
Python
Syntax
crt.FileTransfer.SendXmodem(filepath)
Example
# upload C:\temp\myFile.txt using Xmodem
crt.Screen.Send("rx myFile.txt\n")
crt.Screen.WaitForString("ready to receive")
crt.FileTransfer.SendXmodem("C:\\temp\\myFile.txt")
Description
Initiates file download to download folder.
Remarks
ReceiveXmodem initiates an Xmodem download of a file and saves the file as the specified filename in the session's download folder. Downloaded files are always placed in the session's download folder. Note that the Xmodem send command should be sent or initiated on the remote system before executing ReceiveXmodem for the transfer to proceed properly.
Errors:
1. If the ReceiveXmodem method is executed while not connected, the following script error is generated:
"FileTransfer.ReceiveXmodem: not connected"
2. If a filename passed to ReceiveXmodem is not a simple filename (i.e., if it is a path or contains path separators), the following script error will be generated:
"FileTransfer.ReceiveXmodem: Invalid filename \"% s\". Argument should not include path information."
VBScript
Syntax
crt.FileTransfer.ReceiveXmodem filepath
Example
crt.Screen.Send "sx -X myFile.txt" & vbCR
' Customize the wait string below to match output of remote Xmodem program.
crt.Screen.WaitForString "Give your local XMODEM receive command now." & vbCR
crt.FileTransfer.ReceiveXmodem "yourFile.txt"
Note: When using a WaitForString command as in the above example, the string being waiting for should be the exact Xmodem output, including carriage returns and line feeds.
Python
Syntax
crt.FileTransfer.ReceiveXmodem(filepath)
Example
crt.Screen.Send("sx -X myFile.txt\n")
# Customize the wait string below to match output of remote Xmodem program.
crt.Screen.WaitForString("Give your local XMODEM receive command now.")
crt.FileTransfer.ReceiveXmodem("yourFile.txt")
Note: When using a WaitForString command as in the above example, the string being waiting for should be the exact Xmodem output, including carriage returns and line feeds.