RE: [PHP] Copy Function Errors
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=xx!; $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 -Original Message- From: Boyd, Todd M. [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 16, 2008 2:28 PM To: Wei, Alice J. Cc: php-general@lists.php.net Subject: RE: [PHP] Copy Function Errors -Original Message- From: Wei, Alice J. [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 16, 2008 3:46 PM To: Robert Cummings Cc: php-general@lists.php.net Subject: RE: [PHP] Copy Function Errors ---8--- snip Is there something I could do here to allow my file be copied to the remote server? Use the ftp functions. Thanks for the tip. I have revised my code to: // define some variables $local_file = C:/Inetpub/wwwroot/test/$id/beamdata.tar; $server_file = http://192.168.10.63/test/$id/beamdata.tar;; // set up basic connection $ftp_server=http://192.168.10.63;; $conn_id = ftp_connect($ftp_server); // login with username and password $ftp_user_name=apache; $ftp_user_pass=x; $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); I have put this snippet in the local server of where I want the files to be copied to. However, I see this on my remote server in the logs: 192.168.10.62 - - [16/Jul/2008:16:40:24 -0400] GET /beam_calculation.php?id=145no=16 HTTP/1.1 200 22 - Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727) Is there something I have missed here? Alice, Here are some Wikipedia articles that should give you a good start on understanding the fundamental differences between the two protocols you are confusing with each other: http://en.wikipedia.org/wiki/FTP http://en.wikipedia.org/wiki/HTTP HTTP itself does not intrinsically handle file uploads in a server/client relationship. Web forms that include file uploads generally have a handler function on the other end, and post files via a form element. FTP's main function is the transfer of files (hence [F]ile [T]ransfer [P]rotocol), and is more in line with what you're trying to do here. HTH, Todd Boyd Web Programmer -- 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
Re: [PHP] 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! 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=xx!; $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 -Original Message- From: Boyd, Todd M. [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 16, 2008 2:28 PM To: Wei, Alice J. Cc: php-general@lists.php.net Subject: RE: [PHP] Copy Function Errors -Original Message- From: Wei, Alice J. [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 16, 2008 3:46 PM To: Robert Cummings Cc: php-general@lists.php.net Subject: RE: [PHP] Copy Function Errors ---8--- snip Is there something I could do here to allow my file be copied to the remote server? Use the ftp functions. Thanks for the tip. I have revised my code to: // define some variables $local_file = C:/Inetpub/wwwroot/test/$id/beamdata.tar; $server_file = http://192.168.10.63/test/$id/beamdata.tar;; // set up basic connection $ftp_server=http://192.168.10.63;; $conn_id = ftp_connect($ftp_server); // login with username and password $ftp_user_name=apache; $ftp_user_pass=x; $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); I have put this snippet in the local server of where I want the files to be copied to. However, I see this on my remote server in the logs: 192.168.10.62 - - [16/Jul/2008:16:40:24 -0400] GET /beam_calculation.php?id=145no=16 HTTP/1.1 200 22 - Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727) Is there something I have missed here? Alice, Here are some Wikipedia articles that should give you a good start on understanding the fundamental differences between the two protocols you are confusing with each other: http://en.wikipedia.org/wiki/FTP http://en.wikipedia.org/wiki/HTTP HTTP itself does not intrinsically handle file uploads in a server/client relationship. Web forms that include file uploads generally have a handler function on the other end, and post files via a form
RE: [PHP] 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=xx!; $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
RE: [PHP] Copy Function Errors
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:[EMAIL PROTECTED] Sent: Thursday, July 17, 2008 7:50 AM To: Sam Stelfox Cc: php-general@lists.php.net Subject: RE: [PHP] 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=xx!; $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
RE: [PHP] Copy Function Errors
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. It is funny, because I first started off writing this using shell_exec. I started off doing something like a sftp some_server in the commands within shell_exec() before I got to what I have now, but I stopped that because I don't seem to find any commands that can allow me put passwords and user to the actual client to do it. If there is such a thing as allowing me to feed in all this in one line without using FTP commands, this would be perfect. So far, I have not seen anything like it. I even tried doing an ftp:// on the url of the server, and it gives me this DNS error. I consider that it is easier for me to tar up everything using the command line and transfer that to another server, and then I can do the rest of the untar and other processes without problem. My problem now is that I cannot even transfer the files because I am not able to come up with the suitable commands. Is this an exercise in creating a client app/script to accomplish this? My client wants to have on the client end have all the files transferred back to the different user directories after the back end has some data processing. The client side only sees what is on the server, and not anything from the Linux from my understanding. Alice -Original Message- From: Wei, Alice J. [mailto:[EMAIL PROTECTED] Sent: Thursday, July 17, 2008 7:50 AM To: Sam Stelfox Cc: php-general@lists.php.net Subject: RE: [PHP] 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
Re: [PHP] Copy Function Errors
You need to test using regular FTP, SFTP goes over SSH, while the PHP script your trying to use is making use of regular old FTP. Make sure that the linux machine has the ports open for FTP and that you have an FTP server running on it (SSH is not one). Wei, Alice J. wrote: 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=xx!; $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
Re: [PHP] Copy Function Errors
On Wed, 2008-07-16 at 15:58 -0400, Wei, Alice J. wrote: Hi, I have a snippet of code here: shell_exec(tar cvf /var/www/html/test/$id/data.tar /var/www/html/test/$id/data); $file1=http:/www.mysite.com/test/$id/data.tar; $file2=http://www.mysite2.com/test/$id/.tar;; copy($file1,$file2); I got the following error in the access log of the server: [Wed Jul 16 15:45:57 2008] [error] PHP Warning: copy(http://www.mysite.com/test/145/data.tar) [a href='function.copy'function.copy/a]: failed to open stream: HTTP wrapper does not support writeable connections. in /var/www/html/beam_calculation.php on line 20 Is there something I could do here to allow my file be copied to the remote server? Use the ftp functions. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Copy Function Errors
Hi, I have a snippet of code here: shell_exec(tar cvf /var/www/html/test/$id/data.tar /var/www/html/test/$id/data); $file1=http:/www.mysite.com/test/$id/data.tar; $file2=http://www.mysite2.com/test/$id/.tar;; copy($file1,$file2); I got the following error in the access log of the server: [Wed Jul 16 15:45:57 2008] [error] PHP Warning: copy(http://www.mysite.com/test/145/data.tar) [a href='function.copy'function.copy/a]: failed to open stream: HTTP wrapper does not support writeable connections. in /var/www/html/beam_calculation.php on line 20 Is there something I could do here to allow my file be copied to the remote server? Use the ftp functions. Thanks for the tip. I have revised my code to: // define some variables $local_file = C:/Inetpub/wwwroot/test/$id/beamdata.tar; $server_file = http://192.168.10.63/test/$id/beamdata.tar;; // set up basic connection $ftp_server=http://192.168.10.63;; $conn_id = ftp_connect($ftp_server); // login with username and password $ftp_user_name=apache; $ftp_user_pass=x; $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); I have put this snippet in the local server of where I want the files to be copied to. However, I see this on my remote server in the logs: 192.168.10.62 - - [16/Jul/2008:16:40:24 -0400] GET /beam_calculation.php?id=145no=16 HTTP/1.1 200 22 - Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727) Is there something I have missed here? Alice -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Copy Function Errors
On Wed, Jul 16, 2008 at 4:45 PM, Wei, Alice J. [EMAIL PROTECTED] wrote: Hi, I have a snippet of code here: shell_exec(tar cvf /var/www/html/test/$id/data.tar /var/www/html/test/$id/data); $file1=http:/www.mysite.com/test/$id/data.tar; $file2=http://www.mysite2.com/test/$id/.tar;; copy($file1,$file2); I got the following error in the access log of the server: [Wed Jul 16 15:45:57 2008] [error] PHP Warning: copy(http://www.mysite.com/test/145/data.tar) [a href='function.copy'function.copy/a]: failed to open stream: HTTP wrapper does not support writeable connections. in /var/www/html/beam_calculation.php on line 20 Is there something I could do here to allow my file be copied to the remote server? Use the ftp functions. Thanks for the tip. I have revised my code to: // define some variables $local_file = C:/Inetpub/wwwroot/test/$id/beamdata.tar; $server_file = http://192.168.10.63/test/$id/beamdata.tar;; // set up basic connection $ftp_server=http://192.168.10.63;; $conn_id = ftp_connect($ftp_server); // login with username and password $ftp_user_name=apache; $ftp_user_pass=x; $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); I have put this snippet in the local server of where I want the files to be copied to. However, I see this on my remote server in the logs: 192.168.10.62 - - [16/Jul/2008:16:40:24 -0400] GET /beam_calculation.php?id=145no=16 HTTP/1.1 200 22 - Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727) Is there something I have missed here? Are you considered a special student at the University? -- /Daniel P. Brown Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just $59.99/mo. with no contract! Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Copy Function Errors
On Wed, 2008-07-16 at 16:53 -0400, Daniel Brown wrote: On Wed, Jul 16, 2008 at 4:45 PM, Wei, Alice J. [EMAIL PROTECTED] wrote: Is there something I have missed here? Are you considered a special student at the University? Now, now, no need to be mean. We were all noobs at one time or another. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Copy Function Errors
On Wed, 2008-07-16 at 16:45 -0400, Wei, Alice J. wrote: Hi, I have a snippet of code here: shell_exec(tar cvf /var/www/html/test/$id/data.tar /var/www/html/test/$id/data); $file1=http:/www.mysite.com/test/$id/data.tar; $file2=http://www.mysite2.com/test/$id/.tar;; copy($file1,$file2); I got the following error in the access log of the server: [Wed Jul 16 15:45:57 2008] [error] PHP Warning: copy(http://www.mysite.com/test/145/data.tar) [a href='function.copy'function.copy/a]: failed to open stream: HTTP wrapper does not support writeable connections. in /var/www/html/beam_calculation.php on line 20 Is there something I could do here to allow my file be copied to the remote server? Use the ftp functions. Thanks for the tip. I have revised my code to: // define some variables $local_file = C:/Inetpub/wwwroot/test/$id/beamdata.tar; $server_file = http://192.168.10.63/test/$id/beamdata.tar;; // set up basic connection $ftp_server=http://192.168.10.63;; Shouldn't that be: $ftp_server=192.168.10.63; http:// indicates a protocol and I don't think ftp supports the protocol prefix understood by browsers. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Copy Function Errors
-Original Message- From: Wei, Alice J. [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 16, 2008 3:46 PM To: Robert Cummings Cc: php-general@lists.php.net Subject: RE: [PHP] Copy Function Errors ---8--- snip Is there something I could do here to allow my file be copied to the remote server? Use the ftp functions. Thanks for the tip. I have revised my code to: // define some variables $local_file = C:/Inetpub/wwwroot/test/$id/beamdata.tar; $server_file = http://192.168.10.63/test/$id/beamdata.tar;; // set up basic connection $ftp_server=http://192.168.10.63;; $conn_id = ftp_connect($ftp_server); // login with username and password $ftp_user_name=apache; $ftp_user_pass=x; $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); I have put this snippet in the local server of where I want the files to be copied to. However, I see this on my remote server in the logs: 192.168.10.62 - - [16/Jul/2008:16:40:24 -0400] GET /beam_calculation.php?id=145no=16 HTTP/1.1 200 22 - Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727) Is there something I have missed here? Alice, Here are some Wikipedia articles that should give you a good start on understanding the fundamental differences between the two protocols you are confusing with each other: http://en.wikipedia.org/wiki/FTP http://en.wikipedia.org/wiki/HTTP HTTP itself does not intrinsically handle file uploads in a server/client relationship. Web forms that include file uploads generally have a handler function on the other end, and post files via a form element. FTP's main function is the transfer of files (hence [F]ile [T]ransfer [P]rotocol), and is more in line with what you're trying to do here. HTH, Todd Boyd Web Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Copy Function Errors
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... -Original Message- From: Boyd, Todd M. [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 16, 2008 2:28 PM To: Wei, Alice J. Cc: php-general@lists.php.net Subject: RE: [PHP] Copy Function Errors -Original Message- From: Wei, Alice J. [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 16, 2008 3:46 PM To: Robert Cummings Cc: php-general@lists.php.net Subject: RE: [PHP] Copy Function Errors ---8--- snip Is there something I could do here to allow my file be copied to the remote server? Use the ftp functions. Thanks for the tip. I have revised my code to: // define some variables $local_file = C:/Inetpub/wwwroot/test/$id/beamdata.tar; $server_file = http://192.168.10.63/test/$id/beamdata.tar;; // set up basic connection $ftp_server=http://192.168.10.63;; $conn_id = ftp_connect($ftp_server); // login with username and password $ftp_user_name=apache; $ftp_user_pass=x; $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); I have put this snippet in the local server of where I want the files to be copied to. However, I see this on my remote server in the logs: 192.168.10.62 - - [16/Jul/2008:16:40:24 -0400] GET /beam_calculation.php?id=145no=16 HTTP/1.1 200 22 - Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727) Is there something I have missed here? Alice, Here are some Wikipedia articles that should give you a good start on understanding the fundamental differences between the two protocols you are confusing with each other: http://en.wikipedia.org/wiki/FTP http://en.wikipedia.org/wiki/HTTP HTTP itself does not intrinsically handle file uploads in a server/client relationship. Web forms that include file uploads generally have a handler function on the other end, and post files via a form element. FTP's main function is the transfer of files (hence [F]ile [T]ransfer [P]rotocol), and is more in line with what you're trying to do here. HTH, Todd Boyd Web Programmer -- 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
RE: [PHP] Copy Function Errors
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. What I am trying to accomplish is something simple, which is to copy the files from one single directory, which is already tarred, and have it be copied to a remote server. I am guessing that it is never too difficult to untar it when I get it successfully copied to another server. Right now it appears to me that it keeps on going to the second loop that says it failed, probably because my password and user do not match? I have tried switching that to apache, which is what I set in my httpd.conf for user and group. I was browsing through the articles Todd suggested, and the port number 1025 kept popping up. I am not sure if I am supposed to open this port on my remote and my local machine. I do have ssh, which is port 22 open. Thanks in advance. Alice -regards... -Original Message- From: Boyd, Todd M. [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 16, 2008 2:28 PM To: Wei, Alice J. Cc: php-general@lists.php.net Subject: RE: [PHP] Copy Function Errors -Original Message- From: Wei, Alice J. [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 16, 2008 3:46 PM To: Robert Cummings Cc: php-general@lists.php.net Subject: RE: [PHP] Copy Function Errors ---8--- snip Is there something I could do here to allow my file be copied to the remote server? Use the ftp functions. Thanks for the tip. I have revised my code to: // define some variables $local_file = C:/Inetpub/wwwroot/test/$id/beamdata.tar; $server_file = http://192.168.10.63/test/$id/beamdata.tar;; // set up basic connection $ftp_server=http://192.168.10.63;; $conn_id = ftp_connect($ftp_server); // login with username and password $ftp_user_name=apache; $ftp_user_pass=x; $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); I have put this snippet in the local server of where I want the files to be copied to. However, I see this on my remote server in the logs: 192.168.10.62 - - [16/Jul/2008:16:40:24 -0400] GET /beam_calculation.php?id=145no=16 HTTP/1.1 200 22 - Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727) Is there something I have missed here? Alice, Here are some Wikipedia articles that should give you a good start on understanding the fundamental differences between the two protocols you are confusing with each other: http://en.wikipedia.org/wiki/FTP http://en.wikipedia.org/wiki/HTTP HTTP itself does not intrinsically handle file uploads in a server/client relationship. Web forms that include file uploads generally have a handler function on the other end, and post files via a form element. FTP's main function is the transfer of files (hence [F]ile [T]ransfer [P]rotocol), and is more in line with what you're trying to do here. HTH, Todd Boyd Web Programmer -- 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