- GETTING STARTED
- GUIDES
- COMMANDS
- Server connection
- File Transfer
- Directory operations
- File operations
- Script output
- Miscellaneous
- OTHER
CWDIR
Get the current remote directory
Syntax: CWDIR()
Remarks:
- This command returns the absolute path to the current remote directory. If, for example, the directory name is "images" it will return "/htdocs/images".
- As this command does not accept any parameters the brackets are optional.
Return value:
The return value is the current remote directory. If ScriptFTP is not connected to an FTP server it will return nothing.
See also:
CHDIR
MKDIR
RMDIR
LOCALCWDIR
Example:
# Connect to server
OPENHOST("ftp.myhost.com","myuser","mypassword")
# Create mydir
MKDIR("mydir")
# Go to mydir
CHDIR("mydir")
# Get the current directory
$a=CWDIR()
# The print command should print mydir
PRINT($a)
# Close the connection
CLOSEHOST
Script output:
OPENHOST("ftp.myhost.com","myuser",******)
Connecting to ftp.myhost.com
Connected.
MKDIR("mydir")
Creating remote dir mydir
CHDIR("mydir")
Changing current remote directory to mydir
CWDIR()
/mydir
CLOSEHOST
Disconnected.
Example:
# This will print nothing, ScriptFTP is not connected
PRINT(CWDIR())
# Connect to host
OPENHOST("127.0.0.1","carl","123456")
# Print current remote directory, should be "/"
PRINT(CWDIR())
# Change current remote directory
CHDIR("first_level_subdir")
# Print current remote directory
PRINT(CWDIR())
# Change current remote directory
CHDIR("second_level_subdir")
# Print current remote directory
PRINT(CWDIR())
# Disconnect
CLOSEHOST
Script output:
CWDIR()
OPENHOST("127.0.0.1","carl",******)
Connecting to 127.0.0.1
Connected.
CWDIR()
/
CHDIR("first_level_subdir")
Changing current remote directory to first_level_subdir
CWDIR()
/first_level_subdir
CHDIR("second_level_subdir")
Changing current remote directory to second_level_subdir
CWDIR()
/first_level_subdir/second_level_subdir
CLOSEHOST
Disconnected.

