|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Application developers can seamlessly integrate the Advantage Database install with their application install. Learn the best practices used when setting up silent installs with this seminar. |
|
#1
|
||||
|
||||
|
Hi there.
I was wondering if anyone can help me. I need to be able to have a php script that will read the last updated time on a file located on a remote FTP server, from where the script is located. FTP functions have not been enabled in the version of PHP I have to work with, so I was wondering whether there was any way of doing this with using the fopen commands?? If someone could help me it would be greatly appreciated. Cheers |
|
#2
|
|||
|
|||
|
Of course you _can_ do it.. but is it really worth it..
Anyway you'll obviously need to emulate an FTP user using fput() & fgets() Off the top of my head the commands should go something like: USER username PASS password PORT 127,0,0,1,xyz LIST
__________________
-=-=-=-=-=-=-=-=-=-=-=-=- PHP Scripts n Stuff http://www.bcnstech.net/ -=-=-=-=-=-=-=-=-=-=-=-=- |
|
#3
|
|||
|
|||
|
Bummer. I think the answer's no. A few things occur to me though:
1) if you have curl libraries installed, use that. 2) you could possibly use fsockopen() and speak raw FTP protocol over the socket. very very ugly. (I wouldn't touch it -- I see nih58 beat me to posting this one ) It's ugly because the FTP data and control connections exist on separate ports, and I'm pretty sure you'd need to manually fsockopen() the data port after parsing the negotiation from the data port.... |
|
#4
|
|||
|
|||
|
Yeah.. I think it would be a waste of time trying to talk FTP
![]() Not to mention you'll have even more fun if for some reason you have to use PASV mode due to connection problems.. ![]() |
|
#5
|
||||
|
||||
|
I have no idea if this will work or not. I'm just throwing it out as a hack that I used once.
I had to run an FTP command from a VB program to an IBM mainframe. The FTP command would always work from the command prompt, but would fail using FTP controls and .dll's in my program. Eventually I had to put all of the FTP commands into a text file. This text file had the login, password, command information, etc. I tweaked the flat file until I could run the command ftp -s:filename successfully from the system prompt. When this ran successfully, I then ran it from inside my program using a shell command (in PHP you would want to use the system command). If you were able to pipe the output from the above command into a file on your local machine, you would be able to use fopen to examine the contents of this file for the information you needed. As in my case, it wouldn't matter if your programming language had FTP support as long as you were able to run the command manually from the command prompt. You would have to run a command something like this: ftp -s:commandfile > outputfile Then use fopen to examine the contents of outputfile. If you get really desperate, you might want to give it a try... |
|
#6
|
|||
|
|||
|
Quote:
if you use exec("$command_line",$results); then the results of $command_line being executed would be stored in an array.. obviously $results ![]() |
|
#7
|
|||
|
|||
|
The ftp -s hack is a Windoze idiom. Most *nix ftp clients will let you cut to the chase thusly (consult your manpage):
ftp ftp://[user:password@]host[:port]/file[/] ftp http://host[:port]/file ftp host:[/path/]file[/] and will even expand globs. |
|
#8
|
||||
|
||||
|
Thanks for all the replies...
But what I am after this for is to have a page that shows the clients when a file was last updated on our ftp server so they know how current the download file is. The version of PHP that I am using was not configured with ftp functions and I am unable to change this. So I was wondering if there was a way with the fopen to get the last update time of the file from the remote ftp server...... Does anyone know how I might do this? ![]() |
|
#9
|
|||
|
|||
|
fopen won't do that.
Hold on, you said it's *your* ftp server?? That changes things. There are a number of ways you can work around the ftp limitation if you have access to the file is sits on. If it were me, I'd write a shell script that ran ls -l, pick a port to run it and throw an entry into inetd.conf (essentially using inetd as a daemon to listen for requests on your selected port, and running the ls shell script when it gets a request). This is reasonably secure too (since your script doesn't accept input, it's hard to exploit ). Then all you need to do is use fsockopen() to talk to your little daemon and munge the results in PHP.You could alternatively nfs mount the directories of interest (ugh--don't do this). You could run a httpd and use HEAD requests to get the file modification time, and restrict the httpd so it only talks to your PHP web server. There's a number of other variations on the theme, but if you own the server of interest, lots of possibilities exist. Last edited by linear : July 19th, 2001 at 11:24 PM. |
|
#10
|
|||
|
|||
|
~puts *nix weenie hat on~
Three steps and this is done. 1) write this trivial shell script Code:
#!/bin/sh ls -l /path/to/the/directory and install it somewhere you'll remember (/usr/libexec/mystik.sh is good). Set it executable. 2) edit /etc/services (as root) and add the line mystik 30003/tcp #mystik's disk daemon 3) edit /etc/inetd.conf and add the line mystik stream tcp root /usr/libexec/mystik.sh mystik.sh and restart inetd (kill -HUP `cat /var/run/inetd.pid`) You can telnet to port 30003 on the ftp serve, and if you did the steps right, the output of ls -l should get barfed out at you. Isn't *nix great??!? Last edited by linear : July 19th, 2001 at 11:38 PM. |
|
#11
|
|||
|
|||
|
bump
|
![]() |
| Viewing: Dev Shed Forums > System Administration > FTP Help > NEWBIE:: Using fopen where FTP functions not available |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|