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. The FileTransfer object is not supported with sessions that use TN3270 emulation.
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, Zmodem, or Kermit 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 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 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 " & 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 Y/Zmodem upload list.
Remarks
AddToUploadList places the specified file on a list of files that will be uploaded during the next Y/Zmodem or Kermit upload. Once one or more files have been added to the upload list, a Y/Zmodem or Kermit upload can be initiated by the script sending the appropriate command to the remote system.
Errors:
If the path provided to AddToUploadList is not a valid file, a script error is generated and the following message is displayed:
"FileTransfer.AddToUploadList: <filepath> does not exist."
VBScript
Syntax
crt.FileTransfer.AddToUploadList filepath
Example
crt.FileTransfer.AddToUploadList "c:\temp\File1.txt"
crt.FileTransfer.AddToUploadList "c:\temp\File2.txt"
' Start the upload of the two files...
crt.Screen.Send "rz" & vbCR
Python
Syntax
crt.FileTransfer.AddToUploadList(filepath)
Example
crt.FileTransfer.AddToUploadList("c:\\temp\\File1.txt")
crt.FileTransfer.AddToUploadList("c:\\temp\\File2.txt")
# Start the upload of the two files...
crt.Screen.Send("rz\n")
Description
Clears the Y/Zmodem or Kermit upload list.
Remarks
None.
VBScript
Syntax
crt.FileTransfer.ClearUploadList
Python
Syntax
crt.FileTransfer.ClearUploadList()
Description
Initiates file download to download folder.
Remarks
ReceiveKermit initiates a Kermit download of one of more files from the remote host. Downloaded files are always placed in the session's download folder. Note that the Kermit send command should be sent or initiated on the remote system before executing ReceiveKermit for the transfer to proceed properly.
Errors:
1. If the ReceiveKermit method is executed while not connected, the following script error is generated:
"FileTransfer.ReceiveKermit: not connected"
2. If a transfer is already in progress when this is called, the following script error will be generated:
"FileTransfer.ReceiveKermit: A file transfer cannot be started while another transfer is in progress"
VBScript
Syntax
crt.FileTransfer.ReceiveKermit
Example
crt.Screen.Send "--kermit myfile.txt" & vbCRLF
crt.Screen.WaitForString "--kermit myfile.txt" & vbCRLF
crt.FileTransfer.ReceiveKermit
Python
Syntax
crt.FileTransfer.ReceiveKermit()
Example
crt.Screen.Send("-kermit myFile.txt\n")
crt.Screen.WaitForString("-kermit myFile.txt\n")
crt.FileTransfer.ReceiveKermit()
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."
3. If a transfer is already in progress when this is called, the following script error will be generated:
"FileTransfer.ReceiveXmodem: A file transfer cannot be started while another transfer is in progress"
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 waited 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 waited for should be the exact Xmodem output, including carriage returns and line feeds.
Description
Initiates file download to download folder.
Remarks
ReceiveYmodem initiates a Ymodem download of one of more files from the remote host. Downloaded files are always placed in the session's download folder. Note that the Ymodem send command should be sent or initiated on the remote system before executing ReceiveYmodem for the transfer to proceed properly.
Errors:
1. If the ReceiveYmodem method is executed while not connected, the following script error is generated:
"FileTransfer.ReceiveYmodem: not connected"
2. If a transfer is already in progress when this is called, the following script error will be generated:
"FileTransfer.ReceiveYmodem: A file transfer cannot be started while another transfer is in progress"
VBScript
Syntax
crt.FileTransfer.ReceiveYmodem
Example
crt.Screen.Send "sz --ymodem myfile.txt" & vbCR
crt.Screen.WaitForString "sz --ymodem myfile.txt" & vbCRLF
crt.FileTransfer.ReceiveYmodem
Python
Syntax
crt.FileTransfer.ReceiveYmodem()
Example
crt.Screen.Send("sz -ymodem myFile.txt\n")
crt.Screen.WaitForString("sz -ymodem myFile.txt\r\n")
crt.FileTransfer.ReceiveYmodem()
Description
Sends specified file.
Remarks
SendKermit sends the specified file using the Kermit protocol. Note, the appropriate Kermit receive command should be sent or initiated on the remote system before executing SendKermit for the transfer to begin properly.
Errors:
1. If the SendKermit method is executed while not connected the following script error is generated:
"FileTransfer.SendKermit: not connected"
2. If the file list is empty, the following script error is generated:
"FileTransfer.SendKermit: No files were specified for transfer."
3. If a transfer is already in progress when this is called, the following script error is generated:
"FileTransfer.SendKermit: A file transfer cannot be started while another transfer is in progress"
VBScript
Syntax
crt.FileTransfer.SendKermit
Example
' upload several files using Kermit
crt.FileTransfer.AddToUploadList "c:\temp\File1.txt"
crt.FileTransfer.AddToUploadList "c:\temp\File2.txt"
crt.FileTransfer.AddToUploadList "c:\temp\File3.txt"
crt.Screen.Send "--kermit" & vbCR
crt.FileTransfer.SendKermit
Python
Syntax
crt.FileTransfer.SendKermit()
Example
# upload several files using Kermit
crt.FileTransfer.AddToUploadList("c:\\temp\\File1.txt")
crt.FileTransfer.AddToUploadList("c:\\temp\\File2.txt")
crt.FileTransfer.AddToUploadList("c:\\temp\\File3.txt")
crt.Screen.Send("--kermit\n")
crt.FileTransfer.SendKermit()
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."
3. If a transfer is already in progress when this is called, the following script error is generated:
"FileTransfer.SendXmodem: A file transfer cannot be started while another transfer is in progress"
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
Sends specified file.
Remarks
SendYmodem sends the specified file using the Ymodem protocol. Note, the appropriate Ymodem receive command should be sent or initiated on the remote system before executing SendYmodem for the transfer to begin properly.
Errors:
1. If the SendYmodem method is executed while not connected the following script error is generated:
"FileTransfer.SendYmodem: not connected"
2. If the file list is empty, the following script error is generated:
"FileTransfer.SendYmodem: No files were specified for transfer."
3. If a transfer is already in progress when this is called, the following script error is generated:
"FileTransfer.SendYmodem: A file transfer cannot be started while another transfer is in progress"
VBScript
Syntax
crt.FileTransfer.SendYmodem
Example
' upload several files using Ymodem
crt.FileTransfer.AddToUploadList "c:\temp\File1.txt"
crt.FileTransfer.AddToUploadList "c:\temp\File2.txt"
crt.FileTransfer.AddToUploadList "c:\temp\File3.txt"
crt.Screen.Send "rz --ymodem" & vbCR
crt.FileTransfer.SendYmodem
Python
Syntax
crt.FileTransfer.SendYmodem()
Example
# upload several files using Ymodem
crt.FileTransfer.AddToUploadList("c:\\temp\\File1.txt")
crt.FileTransfer.AddToUploadList("c:\\temp\\File2.txt")
crt.FileTransfer.AddToUploadList("c:\\temp\\File3.txt")
crt.Screen.Send("rz --ymodem\n")
crt.FileTransfer.SendYmodem()