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

onodera koAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
onodera koAuthor Commented:
ty  for help :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.