Jump to content

Strange question - updating file automatically


Rifts

Recommended Posts

Hey guys I don't know if this is possible but here is what I need to do.

 

I have a log (txt file)  on my computer I need it to automatically upload itself to my server every X minutes.

 

Is this possible at all?

Link to comment
Share on other sites

to my server

 

It would probably help if you defined "my server"? Is this a web server? An FTP server? As that would define what protocol(s) could be used to accomplish this.

 

It would also help if you defined - "my computer"? What operating system? How small is x seconds? Does it already have php installed (either as CLI or as a web server extension)?

Link to comment
Share on other sites

oh sorry the file is on my local machine windows 7 and I have a hosting server with godaddy which I use FTP with. I would like to have the updated log file every 3-5 mins.

 

im just not sure how i can do this or what i would need

Link to comment
Share on other sites

Windows has a task scheduler application that lets you setup the equivalent of a cron job.

 

You can make a simple batch file that calls the windows ftp command line client.  If you open up a cmd window and type ftp --help you'll see something like this:

 

C:\Users\David>ftp --help

Transfers files to and from a computer running an FTP server service
(sometimes called a daemon). Ftp can be used interactively.

FTP [-v] [-d] [-i] [-n] [-g] [-s:filename] [-a] [-A] [-x:sendbuffer] [-r:recvb
fer] [-b:asyncbuffers] [-w:windowsize] [host]

  -v              Suppresses display of remote server responses.
  -n              Suppresses auto-login upon initial connection.
  -i              Turns off interactive prompting during multiple file
                  transfers.
  -d              Enables debugging.
  -g              Disables filename globbing (see GLOB command).
  -s:filename     Specifies a text file containing FTP commands; the
                  commands will automatically run after FTP starts.
  -a              Use any local interface when binding data connection.
  -A              login as anonymous.
  -x:send sockbuf Overrides the default SO_SNDBUF size of 8192.
  -r:recv sockbuf Overrides the default SO_RCVBUF size of 8192.
  -b:async count  Overrides the default async count of 3
  -w:windowsize   Overrides the default transfer buffer size of 65535.
  host            Specifies the host name or IP address of the remote
                  host to connect to.

Notes:
  - mget and mput commands take y/n/q for yes/no/quit.
  - Use Control-C to abort commands.

 

The two important arguments to notice are -n and -s.  You can use the -n to turn off the automatic login attempt and the -s to specify a file of commands to be automatically run.

 

So you can make a simple batch file that starts ftp with these parameters and a file that has the commands to PUT the file on the ftp server.

 

 

ftpfile.bat

ftp -n -s:ftp.txt ftp.server.com

 

ftp.txt

user yourusername
ftpuserpassword
binary
literal pasv
put thefilename.txt
quit

 

Then setup this batch file to be called in the windows scheduler application.

 

This is a simple barebones solution which admittedly has absolutely no error checking, but it will get the job done in most cases.  There are scores of more robust solutions out there, but a lot might be overkill for what you're doing. 

Link to comment
Share on other sites

binary tells ftp to use binary transfer mode, rather than the default of ascii.  If you have text, you might want to omit that line.

 

literal pasv tells the server to use pasv mode.  Without going into a long explanation, ftp transfers won't work if the client is behind a nat'd firewall, so it's best to set this mode on in most cases.

Link to comment
Share on other sites

Yes put will overwrite an existing file, so long as the permissions allow it.  Just in case you were wondering, the put command is a commonly used alias for the FTP STOR command.  FTP like a lot of internet protocols has a series of RFC documents that describe it.  If you look in the FTP RFC #959 for the STOR command you'll find this:

 

STORE (STOR)

 

            This command causes the server-DTP to accept the data

            transferred via the data connection and to store the data as

            a file at the server site.  If the file specified in the

            pathname exists at the server site, then its contents shall

            be replaced by the data being transferred.  A new file is

            created at the server site if the file specified in the

            pathname does not already exist.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.