• Status: Solved
  • Priority: Low
  • Security: Public
  • Views: 77
  • Last Modified:

how to detecte the new files and upload this in ftp

hello sorry for my english

is a script to upload files juste me i would like detect the new files in forlder and upload files or folder in my ftp in cron job im a noob in script shell and i need help ty :)
#!/bin/sh
HOST='ftp.example.com'
USER='yourid'
PASSWD='yourpw'
FILE='file.txt'

ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
binary
put $FILE
quit
END_SCRIPT
exit 0

Open in new window

0
onodera ko
Asked:
onodera ko
1 Solution
 
8046586Commented:
I would recommend you buying Best Sync, and you have all possible combinations: http://www.risefly.com/fsedwld.htm

It is not a freeware software, but it's most complete sync toy I ever tested. 2 Years ago I was doing a survey and tested over 20 sync products; this one was the ultimate winner in features and performances.
0
 
Prabhin MPEngineer-TechOPSCommented:
#!/bin/bash

HOST=ftp.xxxxxx.com
USER=username
PASS=password


SOURCE=/ldaphome/WorkFiles/Customers/ZILVERZOOM/PRODUCTIONPHOTOS/  #Source Directory

td=`date +%Y%m%d`  # Today's date in YYYYMMDD format
oldd=$(date -d "-1 days" +%Y%m%d)  # Yesterday's date in YYYYMMDD format

TARGET="ZilverPhoto_${td}/" # Target Directory Name

# Copy everything modified after yesterday to this folder
RUN="/usr/local/bin/cpafter.sh -vf -a $oldd -s $SOURCE -t /tmp/$TARGET"
$RUN

# Run wput and upload Directory to ZilverZoom FTP
cd /tmp
wput $TARGET ftp://${USER}:${PASS}@${HOST}/

# Delete the temp directory
rm -rf $TARGET
0
 
onodera koAuthor Commented:
cool ty i have an oder question is possible to hide the user and password in the script ?
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
Prabhin MPEngineer-TechOPSCommented:
hi ,
I'm not sure about that, I have an alternative solution for that you can encrypt the entire script itself . so nobody will be able to see the username and password. please find the following Link for encryption,
https://googleweblight.com/i?u=https://n0where.net/how-to-encrypt-bash-script&grqid=vTMOZwoJ&hl=en-IN
0
 
onodera koAuthor Commented:
i test the script and i have an error

#!/bin/bash

HOST=ftp.ftp.com
USER=ftpuser
PASS=pass

SOURCE=/home/gaaara/ #Source Directory

td=`date +%Y%m%d`  # Today's date in YYYYMMDD format
oldd=$(date -d "-1 days" +%Y%m%d)  # Yesterday's date in YYYYMMDD format

TARGET="torrents${td}/" # Target Directory Name

# Copy everything modified after yesterday to this folder
RUN="/home/gaaara/torrents -vf -a $oldd -s $SOURCE -t tmp/$TARGET"
$RUN

# Run wput and upload Directory to ZilverZoom FTP
cd tmp
wput $TARGET ftp://${USER}:${PASS}@${HOST}/

# Delete the temp directory
rm -rf $TARGET

Open in new window


Error: File `torrents20180106/' does not exist. Don't know what to do about this URL.
Nothing done. Try `wput --help'.

Open in new window

0
 
skullnobrainsCommented:
since you erase files after copying them

find /home/gaara -maxdepth 1 | while read file
do wput "/home/gaara/$file" ftp://... && rm "/home/gaara/$file"
done

Open in new window

you can run this every minute in cron

if you do not want passwords in the script, you may want to use scp or sftp with ssh keys

setup ssh keys is well described on the internet but pretty much boils to running successively "ssh-keygen" and "ssh-copy-id TARGETSERVER" ( assuming you have a system account on the target server and know the password )"

find /home/gaara -maxdepth 1 | while read file
do scp -r "/home/gaara/$file" scp://HOSTNAME:/TARGET/DIR/ && rm "/home/gaara/$file"
done

Open in new window

0
 
onodera koAuthor Commented:
ty  for help :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now