I am trying to use the php ftp_* functions to access files on an OpenVMS UCX
FTP server. I can log in and list the files, but I can't use ftp_get() to
get any of them. Instead I get a 'file not found' back from ftp_get().
I think the problem is in OpenVMS naming conventions. OpenVMS saves files
with a semicolon and a version number appended to the end. So instead of
overwriting files, it increments the version number. In my case, I have
directory with ~100 files, all with the same name and different version
numbers. For instance:
FILENAME.EXT;1
FILENAME.EXT;2
{...}
FILENAME.EXT;100
...so my first suspicion is that ftp_get() doesn't understand what to do
with the semicolon.
STFW turns up a bug in PHP where garbage is appended to ASCII type transfers
from OpenVMS, but I don't think that is relevant to this problem. I will
likely have to deal with this if I can get the file to transfer, but one
step at the time.
If I use 'get' in a command line FTP client from the LAMP box I'm developing
this on, I just specify the version number as part of the filename as you
would expect.
I have tried escaping the semicolon with a backslash. ftp_get() returns a
"Warning: ftp_get: File specification syntax error" message.
This is my first foray into the ftp_* functionality of PHP. Hopefully,
someone here will have had to deal with this already, and will have an
answer. Here is the code I have so far, for what its worth:
<?php
// This is a 'one use' utility on a private server, no need to sanitize
$filename=$_POST['filename'];
// Debugging
$filename=preg_replace('/;/','\;',$filename);
echo $filename;
$local_file='/tmp/'.$filename;
$ftp_server='host';
$ftp_username='username';
$ftp_userpass='password';
// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_username, $ftp_userpass);
// check connection
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
echo "Attempted to connect to $ftp_server for user $ftp_user_name";
exit;
}
// try to download
if (ftp_get($conn_id, $local_file, $filename, FTP_ASCII)) {
echo "Successfully written to $local_file\n";
} else {
echo "There was a problem\n";
}
ftp_close($conn_id);
?>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php