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
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"
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
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
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 t
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=145&no=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=145&no=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. -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=145&no=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
> -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=145&no=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
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) [ > href='function.copy'>function.copy]: 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
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, 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) [> href='function.copy'>function.copy]: 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=145&no=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? -- 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
> 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) [ href='function.copy'>function.copy]: 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=145&no=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, 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) [ href='function.copy'>function.copy]: 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
[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) [function.copy]: 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? Anything is appreciated. Alice == Alice Wei MIS 2009 School of Library and Information Science Indiana University Bloomington [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] copy function?
Hello Garth, Tuesday, November 16, 2004, 2:42:31 PM, you wrote: GHS> Which event handler of the button should I use and hoe should I construct GHS> the function? This is a JavaScript question. Please post to a JavaScript mailing list. Best regards, Richard Davey -- http://www.launchcode.co.uk - PHP Development Services "I am not young enough to know everything." - Oscar Wilde -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] copy function?
On Tue, 2004-11-16 at 16:42 +0200, Garth Hapgood - Strickland wrote: > I have a button which I want to add a function to, so that when it is > clicked, the data from one will be copied to another > > Which event handler of the button should I use and hoe should I construct > the function? > > Garth > Php doesn't do anything like this...unless you post a form. Try javascript. -Robby -- /*** * Robby Russell | Owner.Developer.Geek * PLANET ARGON | www.planetargon.com * Portland, OR | [EMAIL PROTECTED] * 503.351.4730 | blog.planetargon.com * PHP/PostgreSQL Hosting & Development *--- Now supporting PHP5 --- / signature.asc Description: This is a digitally signed message part
Re: [PHP] copy function?
> I have a button which I want to add a function to, so that when it is > clicked, the data from one will be copied to another > > Which event handler of the button should I use and hoe should I construct > the function? onclick. This is not really a php question. do some googleing for javascript. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] copy function?
[snip] I have a button which I want to add a function to, so that when it is clicked, the data from one will be copied to another Which event handler of the button should I use and hoe should I construct the function? [/snip] Both textareas on the same page? Want to do the copy without making a trip to the server? I think you want JavaScript for this. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] copy function?
On Tue, 16 Nov 2004 16:42:31 +0200, Garth Hapgood - Strickland <[EMAIL PROTECTED]> wrote: > I have a button which I want to add a function to, so that when it is > clicked, the data from one will be copied to another > > Which event handler of the button should I use and hoe should I construct > the function? That's Javascript, not PHP. -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] copy function?
I have a button which I want to add a function to, so that when it is clicked, the data from one will be copied to another Which event handler of the button should I use and hoe should I construct the function? Garth -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] copy function
Is there a way to copy a file from 1 server to a different one? I have this code in a win 2k server, and i try to copy the file to a win NT server: if (is_file($file_att)) if (copy($file_att,'\servername\folder\'.$file_name)) echo "succesful"; else echo "failure"; It gives me this warning: Warning: Unable to create '\servername\folder\image.jpg': Invalid argument in D:\Intranet\sitio\Documentos\copyf.php on line 161 failure I need this to work on any computer of the network. What kind of permission do I need so any computer can use this script? Thanks for the help. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Copy function usage ?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 look in httpd.conf to get the user name, then chown the directory to that user ex. chown apache:apache ./dir/ chmod 755 ./dir/ and make sure that you change permissions to all files that you write into the directory to be read-write only (not executable), chown 644 filename and that you put newly uploaded files into a directory *outside* the document root of your webserver (so some random person cannot just upload any random file to your server and have immediate access to it) > -Original Message- > From: Jon Farmer [mailto:[EMAIL PROTECTED]] > Sent: Thursday, August 09, 2001 11:41 AM > To: Tamas Bucsu; [EMAIL PROTECTED] > Subject: RE: [PHP] Copy function usage ? > > > You need to make sure that what ever user the webserver/php runs under has > permissions to read from the source folder/file and write permission for the > destination folder/file. > > Common users for apache/php are "nobody" or "apache" > > regards > > Jon > > Jon Farmer > Systems Programmer > Entanet International Ltd www.enta.net > Tel 01952 428969 > Mob 07968 524175 > > -Original Message- > From: Tamas Bucsu [mailto:[EMAIL PROTECTED]] > Sent: 09 August 2001 16:36 > To: [EMAIL PROTECTED] > Subject: [PHP] Copy function usage ? > > > Hi guys, > > I have a problem that's killin' me. As I'm not very good at Linux I don't > know how to set the properties of the folder pics to be able to use the copy > function. (If I'm right and the problem is not some else) Please help. > Here's the code: > > if (file_exists($userfile)) { > copy("$userfile","pics/".$userfile); > } else { > echo "Nem sikerül a következõ file-t feltölteni:".$userfile; > } > > thx > > Tamas Bucsu > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com> iQA/AwUBO3KwG8aXTGgZdrSUEQLcsACfaWVByz/Q+Tu5WZgWp+JkwZ+mkOMAnRlG TTQNXq4GlF6pDxl+ufAbNoZw =1pnp -END PGP SIGNATURE- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Copy function usage ?
You need to make sure that what ever user the webserver/php runs under has permissions to read from the source folder/file and write permission for the destination folder/file. Common users for apache/php are "nobody" or "apache" regards Jon Jon Farmer Systems Programmer Entanet International Ltd www.enta.net Tel 01952 428969 Mob 07968 524175 -Original Message- From: Tamas Bucsu [mailto:[EMAIL PROTECTED]] Sent: 09 August 2001 16:36 To: [EMAIL PROTECTED] Subject: [PHP] Copy function usage ? Hi guys, I have a problem that's killin' me. As I'm not very good at Linux I don't know how to set the properties of the folder pics to be able to use the copy function. (If I'm right and the problem is not some else) Please help. Here's the code: if (file_exists($userfile)) { copy("$userfile","pics/".$userfile); } else { echo "Nem sikerül a következõ file-t feltölteni:".$userfile; } thx Tamas Bucsu -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Copy function usage ?
Hi guys, I have a problem that's killin' me. As I'm not very good at Linux I don't know how to set the properties of the folder pics to be able to use the copy function. (If I'm right and the problem is not some else) Please help. Here's the code: if (file_exists($userfile)) { copy("$userfile","pics/".$userfile); } else { echo "Nem sikerül a következõ file-t feltölteni:".$userfile; } thx Tamas Bucsu