Script to upload latest file to other server via FTP
Hello,
I have a script that finds the latest version of a file in a folder on my Minecraft server. I'm trying to come up with something that will then FTP that file over to my fileserver.
Here's what I have that finds the newest file:
find /home/mc/archive/sbhouse -type f -mtime +45 -exec ls {} \;
So I created a ".netrc" file in my home folder. Do I need to chmod it in any way?
chmod 600 it.
Quote:
Then, I'll create a new .SH script like this:
You removed a few too many newlines.
I doubt you actually want to upload these files into root, /filename. (Though you might have a chroot going on, for all I know.) Put them where you actually want them to go...
Quote:
So would this copy the file to the ftproot of the minecraft user on the other server?
I know nothing of minecraft's internal organization, you've shown nothing of it, and you provided the find yourself. I honestly don't know if it does what you want, your requirements aren't clear.
Try replacing ftp 192.168.0.10 with cat, see what your program prints. Is it naming the files you want for upload?
Last edited by Corona688; 03-06-2012 at 06:18 PM..
I figured I would configure the root of the FTP login for the "minecraft" user to go to the /home/minecraft folder on my FTP server, the home folder for that user. So, yes, I guess that's a chroot. But I have that configured via the FTP server software through Webmin. Can you tell I'm still new to Linux?
As for the minecraft structure, this is simply a daily tarball that I have built of the entire structure of the server. So the find statement I was using before (if it had the -1 vs. the +45 as the argument for mtime) will find only one file each time it is run, the one that is within 24 hours of now.
I'll test tonight when I get home from work. Was just curious to see if I understood you correctly. And thanks for correcting my hack-job of quoting the scripting you did.
I figured I would configure the root of the FTP login for the "minecraft" user to go to the /home/minecraft folder on my FTP server, the home folder for that user. So, yes, I guess that's a chroot.
The login folder might not be the same as the root folder. If you can ftp into it with commandline FTP then 'cd /' and see etc, usr, sbin, and stuff, then it's not a chroot.
IF you leave the second filename, the destination filename, off completely it should just end up in the login folder. I wasn't certain the login folder was actually your minecraft folder at the time, so tried to cover all possibilities.
Quote:
As for the minecraft structure, this is simply a daily tarball that I have built of the entire structure of the server. So the find statement I was using before (if it had the -1 vs. the +45 as the argument for mtime) will find only one file each time it is run, the one that is within 24 hours of now.
I wouldn't bother with find then -- just ls -t and grab the topmost. That makes it a lot simpler.
That <<EOF ... EOF pattern is a here-document, which is equivalent to feeding the section of text inside it into ftp's standard input with a pipe. The ending EOF must be at the very beginning of the line, or it won't be considered the end of the here-document...
For that matter, why not make uploading the tarball part of the process which creates it?
find . -type f -mtime -1
It comes up with only one file, the latest tarball in the folder.
---------- Post updated at 02:50 PM ---------- Previous update was at 02:46 PM ----------
ls -t | head -n 1
That also finds the newest file! Cool. Something new.
The tarball is created by a series of scripts provided in a Minecraft management suite. I choose not to alter those scripts as they work so well and the last thing I want to do is jeopardize the stability of that system. So I figured I'd follow behind and do this.
Any chance you could do a pastebin of your latest suggestion? I'm not sure the <<EOF thing is where you say it's supposed to be. Just want to be sure.
Hi,
I want to create a script that parses the content of a file (on each line there is a filename with full path containing the latest fiels created on that day) and uploads every file to a ftp location.
Any elegant way to do it ? (4 Replies)
Hello people,
I have to download, with a scheduled script, the latest file from an FTP server.
In the remote DIR, named .../TEKNONET/60468/, every night a CDR file like this gets uploaded into it: 000006046820151122N001.CDR, so my script will have to download every day the previous day... (12 Replies)
Hi,
Im a newbie with programming and shell scripting. Im running OSX/Mac and Darwin.
I would like to create a shell script that would :
1. Search a Volume and directory (including subdirectories) for a file that :
* filename ends with ”_Highres.pdf” and
* the file creation date of... (8 Replies)
Hello this is my first post in this forum , I dont want to be unhappy..
I am writing one script but facing difficulty to find the latest file with some new pattern
My requirement is
1. The file is coming like "ABCD-23220140303" at FTP server once in a week.
2. script will run on daily... (3 Replies)
HI,
I need a script to find new files that created after 6:00 from /home/ugh /demo/conn /UAT/d01 and upload them into ftp server according to system date:
Please help me (1 Reply)
hello,
I'm trying to upload a file to this ftp server and others ftp://ftp.byethost12.com as you can see in the output of CURL using the -v option
curl reports that the upload succeeded but when i connected to the server with file-zilla there is no file uploaded the same command
upload files... (5 Replies)
How to FTP the latest file, based on date, from a remote server through a shell script?
I have four files to be FTP'ed from remote server.
They are of the following format.
build1_runtime_mmddyyyy.txt
build2_runtime_mmddyyyy.txt
build3_runtime_mmddyyyy.txt
buifile_count_mmddyyyy.txt
... (9 Replies)
Hello everyone,
sorry for the title, most of you must getting sick of reading something like
this, but I haven't found a solution, although I found many threads according
to it.
I'm working on a bash script that connects to a network printer with ftp
where I want to upload a pdf created... (3 Replies)
Hi
I'm having some trouble with a bash shell script that I'm writing. In the script, I'm trying to upload a file to a backup repository using ftp, but the whole file doesn't get uploaded.
This is the file's properties at the start (I've highlighted the file size in red):
-rw-r--r-- 1 root... (2 Replies)
Hello All,
Hope u r doing fine.
I'm writing a shell script to ftp the latest file having pericular convention as 'ULTI_15072007043205.txt' on daily basis.
Now the date & timing of the file geleration isnt constant, so the file name daily varies as per the date & timing of generation.
Can anyone... (7 Replies)