This concept can be used to execute FTP commands on specified FTP server.
This concept is able to login into a FTP server, view and change the working directory,
create, remove and list files and directories on the FTP server and change transefer mode
to ASCII and to BINARY mode.
$ftpCl typeof FTPClient
#open FTP conncetion to host in dir named directory
if ( $ftpCl.openConnection("ftp://hostName/dirName") ) then [
#login into FTP server using specified username and password
if ( $ftpCl.login("userName","passwd") ) then [
#rename oldDir directory to newDir
if $ftpcl.rename("/oldDirName", "/newDirName") then [
print "OK"]
#show working directory
print $ftpcl.getWorkingDirectory]]
Methods inherited from: Concept
| cloneConcept, extendsConcept, fromXML, getAllInheritedConcepts, getConceptAttribute, getConceptAttributeField, getConceptAttributeFields, getConceptAttributes, getConceptConstructors, getConceptElement, getConceptElementField, getConceptElementFields, getConceptElements, getConceptLabel, getConceptMethod, getConceptMethods, getConceptOperators, getConceptType, getErrorHandler, getInheritedConcepts, getResourceURI, hasConceptAttribute, hasConceptElement, hasConceptMethod, hasPath, isHidden, loadContent, setConceptLabel, setErrorHandler, setHidden, setShowEmpty, showEmpty, toTXT, toXML, setResourceURI |
|
| Label: | errorCode |
| Type: | Integer |
| Is Static: | false |
| Is Hidden: | false |
| Show Empty: | true |
Stores that error code with which the last executed command returned.
| Label: | errorMessage |
| Type: | String |
| Is Static: | false |
| Is Hidden: | false |
| Show Empty: | true |
Stores that error message with which the last executed command returned.
| Parameters: |
| $path : | The new directory path. |
|
| Exceptions: |
FTPOperationException :
(Error) | If unable to execute FTP command on FTP server.. |
FTPOperationException :
(Warning) | If can not change the working directory that is not exists. |
Returns true if the changing of the current working directory to the
directory specified in $path was successfull, false otherwise.
$ftp typeof FTPClient
if ($ftp.openConnection("ftp://hostName/mydir")) then [
if ($ftp.login("guest", "guest")) then [
print $ftp.getWorkingDirectory
$ftp.changeWorkingDirectory("..")
print $ftp.getWorkingDirectory
$ftp.changeWorkingDirectory("mydir")
print $ftp.getWorkingDirectory
]
$ftp.closeConnection
]
-- the result is --
/mydir
/
/mydir
| Exceptions: |
connectionException :
(Error) | If an error occured when the FTPClient try to close the FTP connection.. |
Close the current connection.
$ftp typeof FTPClient
if ($ftp.openConnection("ftp://hostName/mydir")) then [
if ($ftp.login("guest", "guest")) then [
print $ftp.getWorkingDirectory
]
$ftp.closeConnection
]
-- the result is --
/mydir
| Parameters: |
| $path : | The path to the file or directory you want to delete. |
|
| Exceptions: |
FTPOperationException :
(Error) | If unable to execute FTP command on FTP server.. |
FTPOperationException :
(Warning) | If the directory is not exists. |
Deletes the file or directory specified by the $path.
$ftp typeof FTPClient
if ($ftp.openConnection("ftp://hostName/mydir")) then [
if ($ftp.login("guest", "guest")) then [
if ($ftp.putFile("test.txt", "This is a test.")) then [
$ftp.getLinks
$ftp.delete("test.txt")
$ftp.getLinks
]
]
$ftp.closeConnection
]
-- the result is --
-rw-r--r-- 1 guest guest 165392 Apr 22 12:38 car.jpg
-rw-r--r-- 1 guest guest 38472 Jul 31 17:51 report.doc
-rw-r--r-- 1 guest guest 15 Aug 15 21:43 test.txt
-rw-r--r-- 1 guest guest 165392 Apr 22 12:38 car.jpg
-rw-r--r-- 1 guest guest 38472 Jul 31 17:51 report.doc
| Exceptions: |
FTPOperationException :
(Error) | If unable to execute FTP command on FTP server.. |
Returns the specified $file's content.
If the file content is text this concept return a String concept
otherwise return ByteArray concept.
$ftp typeof FTPClient
if ($ftp.openConnection("ftp://hostName/mydir")) then [
if ($ftp.login("guest", "guest")) then [
if ($ftp.putFile("test.txt", "This is a test.")) then [
print $ftp.getFile("test.txt")
]
]
$ftp.closeConnection
]
-- the result is --
This is a test.
| Exceptions: |
FTPOperationException :
(Error) | If unable to execute FTP command on FTP server.. |
Returns a series which contains all directories in the current working
directory.
$ftp typeof FTPClient
if ($ftp.openConnection("ftp://hostName/mydir")) then [
if ($ftp.login("guest", "guest")) then [
$ftp.getLinks
]
$ftp.closeConnection
]
-- the result is --
-rw-r--r-- 1 guest guest 165392 Apr 22 12:38 car.jpg
drwxrwsr-x 2 guest guest 96 Jul 10 13:08 docs
-rw-r--r-- 1 guest guest 38472 Jul 31 17:51 report.doc
-rw-r--r-- 1 guest guest 15 Aug 15 21:43 test.txt
| Parameters: |
| $path : | The path to the directory. |
|
| Exceptions: |
FTPOperationException :
(Error) | If unable to execute FTP command on FTP server.. |
Returns a series which contains all directories in the specified $path.
$ftp typeof FTPClient
if ($ftp.openConnection("ftp://hostName/mydir")) then [
if ($ftp.login("guest", "guest")) then [
$ftp.getLinks("docs")
]
$ftp.closeConnection
]
-- the result is --
-rw-r--r-- 1 guest guest 21 Jul 18 10:58 notes.txt
-rw-r--r-- 1 guest guest 82 Jul 15 17:02 log.txt
| Exceptions: |
FTPOperationException :
(Error) | If unable to execute FTP command on FTP server.. |
Returns the current working directory.
$ftp typeof FTPClient
if ($ftp.openConnection("ftp://hostName/mydir")) then [
if ($ftp.login("guest", "guest")) then [
print $ftp.getWorkingDirectory
]
$ftp.closeConnection
]
-- the result is --
/mydir
Returnes true if the error code is a positive complection response,
false otherwise.
$ftp typeof FTPClient
if ($ftp.openConnection("ftp://hostName/mydir")) then [
if ($ftp.login("guest", "guest")) then [
print $ftp.isPositiveCompletion
]
$ftp.closeConnection
]
-- the result is --
true
| Parameters: |
| $userName : | The user's name with which to connect. |
| $password : | The user's password with which to connect. |
|
| Exceptions: |
connectionException :
(Warning) | If you are not connected to FTP server.. |
connectionException :
(Error) | If unable to login to FTP server, the FTP connection is closed. |
Returns true if the logging in with the specified $userName and
$password was successfull, false otherwise.
$ftp typeof FTPClient
if ($ftp.openConnection("ftp://hostName/mydir")) then [
print $ftp.login("guest", "guest")
]
-- the result is --
true
| Exceptions: |
connectionException :
(Error) | If an error occured when you try to logout from the FTP server.. |
Returns true if the logging out was successfull, false otherwise.
$ftp typeof FTPClient
if ($ftp.openConnection("ftp://hostName/mydir")) then [
if ($ftp.login("guest", "guest")) then [
print $ftp.logout
]
$ftp.closeConnection
]
-- the result is --
true
| Parameters: |
| $path : | The path to the directory which will be created. |
|
| Exceptions: |
FTPOperationException :
(Error) | If unable to execute FTP command on FTP server.. |
FTPOperationException :
(Warning) | If the directory is already exists. |
Creates a new subdirectory on the FTP server in the current directory
(if a relative pathname is given) or where specified (if an absolute
pathname is given) and returns true if the directory creation was
successfull, false otherwise.
$ftp typeof FTPClient
if ($ftp.openConnection("ftp://hostName/mydir")) then [
if ($ftp.login("guest", "guest")) then [
$ftp.getLinks
$ftp.mkdir("tmp")
$ftp.getLinks
]
$ftp.closeConnection
]
-- the result is --
-rw-r--r-- 1 guest guest 165392 Apr 22 12:38 car.jpg
drwxrwsr-x 2 guest guest 96 Jul 10 13:08 docs
-rw-r--r-- 1 guest guest 38472 Jul 31 17:51 report.doc
-rw-r--r-- 1 guest guest 15 Aug 15 21:43 test.txt
-rw-r--r-- 1 guest guest 165392 Apr 22 12:38 car.jpg
drwxrwsr-x 2 guest guest 96 Jul 10 13:08 docs
-rw-r--r-- 1 guest guest 38472 Jul 31 17:51 report.doc
-rw-r--r-- 1 guest guest 15 Aug 15 21:43 test.txt
drwxrwsr-x 2 guest guest 48 Aug 02 13:08 tmp
| Parameters: |
| $url : | The url to the remote host. |
|
| Exceptions: |
unknownHostException :
(Error) | If missing a host name form URL. |
connectionException :
(Error) | If the FTP server refuzed connection. |
unsupportedProtocolException :
(Error) | If the protocol is unsupported by the FTPClient.. |
badURLException :
(Error) | If the URL isn't valid. |
IOException :
(Error) | If the socket could not be opened. |
Returns true if the connection to the remote host with the specified
$url was successfull, false otherwise.
$ftp typeof FTPClient
print $ftp.openConnection("ftp://hostName/mydir")
-- the result is --
true
| Parameters: |
| $fileName : | The file name which will be stored. |
| $content : |
The content of the stored file.
The content must be a String or a ByteArray concept. |
|
| Exceptions: |
FTPOperationException :
(Error) | If unable to execute FTP command on FTP server. |
unsupportedContentException :
(Error) | If $content parameter isn't a String or a ByteArray concept. |
Returns true if the store of the file was successfull, false otherwise.
$ftp typeof FTPClient
if ($ftp.openConnection("ftp://hostName/mydir")) then [
if ($ftp.login("guest", "guest")) then [
if ($ftp.putFile("test.txt", "This is a test.")) then [
print $ftp.getFile("test.txt")
]
]
$ftp.closeConnection
]
-- the result is --
This is a test.
| Parameters: |
| $oldName : | The name of the remote file to rename. |
| $newName : | The new name of the remote file. |
|
| Exceptions: |
FTPOperationException :
(Error) | If unable to execute FTP command on FTP server.. |
FTPOperationException :
(Warning) | If can not rename the directory. |
Returns true if the renaming of the remote file was successfull, false
otherwise.
$ftp typeof FTPClient
if ($ftp.openConnection("ftp://hostName/mydir")) then [
if ($ftp.login("guest", "guest")) then [
if ($ftp.putFile("test.txt", "This is a test.")) then [
$ftp.getLinks
$ftp.rename("test.txt", "text.tst")
$ftp.getLinks
]
]
$ftp.closeConnection
]
-- the result is --
-rw-r--r-- 1 guest guest 165392 Apr 22 12:38 car.jpg
-rw-r--r-- 1 guest guest 38472 Jul 31 17:51 report.doc
-rw-r--r-- 1 guest guest 15 Aug 15 21:43 test.txt
-rw-r--r-- 1 guest guest 165392 Apr 22 12:38 car.jpg
-rw-r--r-- 1 guest guest 38472 Jul 31 17:51 report.doc
-rw-r--r-- 1 guest guest 15 Aug 15 21:43 text.tst
| Parameters: |
| $isBinary : |
The logical value to set. If true the file type will be set to binary,
if false the file type will be ascii.
|
|
| Exceptions: |
FTPOperationException :
(Error) | If unable to execute FTP command on FTP server.. |
FTPOperationException :
(Warning) | If can not change transfer mode to binary. |
Sets the file type.
$ftp typeof FTPClient
if ($ftp.openConnection("ftp://hostName/mydir")) then [
if ($ftp.login("guest", "guest")) then [
print $ftp.setBinaryMode(TRUE)
]
$ftp.closeConnection
]
-- the result is --
true