RE: Copy Function Errors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Is there some reason that you can't use a simple samba server from the
linux, to windows box? Or just do a scp copy, or just a simple ftp transfer.
All of these can be done from the cmd line.

Is this an exercise in creating a client app/script to accomplish this?

just trying to understand a little more about what you're trying to do in
transferring the files...


-----Original Message-----
From: Wei, Alice J. [mailto:ajwei@xxxxxxxxxxx]
Sent: Thursday, July 17, 2008 7:50 AM
To: Sam Stelfox
Cc: php-general@xxxxxxxxxxxxx
Subject: RE:  Copy Function Errors


It sounds to me like your problem is now about the authentication. By
default most linux distributions do not give apache a password. I
personally think using apache would be a bad idea. How about creating a
user on the linux box your trying to put the files on to make it's
primary group apache (make sure the group can write to the folder you
are putting the files in) and give it a password that is a random string
of 20 characters (http://www.goodpassword.com) that only your script knows.

Try testing to make sure you can ftp to the server using a normal ftp
client (ftp for the linux command line or http://filezilla-project.org/
is a good one if your using windows) using the account you created. Make
sure you can put files in the directory you will be with the script.

If this all works and your script using the new account is not, I'm sure
we can help you debug it further :). Good luck!

You are right, there is something terribly wrong with my authentication. I
have added one user called test and gave it a fixed password. Since the
information where I intend to extract from is a Linux machine, and the
location where it is meant to copy to is the Windows server. I tested it
using the SSH Shell from the Windows machine to make sure it is working. It
does.

I have modified the script where it does the authentication to the
following:

// set up basic connection
$ftp_server="192.168.10.63";
$conn_id = ftp_connect($ftp_server) or die ("Failed to Connect");

// login with username and password
$ftp_user_name="somename";
$ftp_user_pass="somepass";
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass) or die
("Failed to Login");

// try to download $server_file and save to $local_file
if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
    echo "Successfully written to $local_file\n";
} else {
    echo "There was a problem\n";
}

When I executed the script, it now prompts me back "Failed" to Connect" as
in the first die statement. I am confused because when I use the SSH with
Filezilla or other SFTP clients, I used the same user and passwords here and
have received no errors.

I don't know if I should put the user_name and user_pass from this file to
the httpd.conf, though. Currently, this is not set.

Thanks in advance.

Alice

Wei, Alice J. wrote:
> Hi Alice...
>
> I just caught/saw this thread. I'm asuming you haven't found/solved what
you're trying to do.
>
> So, What exactly are you trying to accomplish? What OS are you running on
both the client/server machine? Are you trying to copy from a directory on
one box, to a directory on another box? Is this a one time thing? Are the
boxes on the same network (physically close together)? Are you able to login
to the remote box from your initial server?
>
> Let me know what you're looking to do, and I can probably get you going.
>
> -regards...
>
>   All I wanted to do is to copy the file that is sitting on a remote
machine to have it copied it over to another remote machine. Since I put the
code snippet below on the server that is supposed to accept the files, I
would say I am "downloading" the file here from a remote server to a local
server.
>
>   It is weird, because I followed Robert's advice and cut out the http://
snippet in my ftp server address, and I have tried both the apache and root
password of the actual log in of the FTP, which neither of them worked. Both
of the servers have the firewall DNS set up properly, and in my PHP info
page, it appears that my FTP is enabled.
>
> Is there something else I have missed?
>
> // define some variables
> $local_file = "C:/Inetpub/wwwroot/test/$id/data.tar";
> $server_file = "http://192.168.10.63/test/$id/data.tar";;
>
> // set up basic connection
> $ftp_server="192.168.10.63";
> $conn_id = ftp_connect($ftp_server);
>
> // login with username and password
> $ftp_user_name="root";
> $ftp_user_pass="xxxxxx!";
> $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
>
> // try to download $server_file and save to $local_file
> if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
>     echo "Successfully written to $local_file\n";
> } else {
>     echo "There was a problem\n";
> }
>
> // close the connection
> ftp_close($conn_id);
>
> Thanks in advance.
>
> Alice
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux