LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Automate FTP / Scripting FTP Transfers files from linux to windows m/c (https://www.linuxquestions.org/questions/programming-9/automate-ftp-scripting-ftp-transfers-files-from-linux-to-windows-m-c-785040/)

ashishshukla 01-27-2010 06:22 AM

Automate FTP / Scripting FTP Transfers files from linux to windows m/c
 
Hi Friends,

I need to transfer file from linux to window m/c through ftp in daily basis. Daily file name change to today's date (e.g fullbackup_yyyymmdd) and previous date's file is deleted.

as i m not good in shell scripting. please help me how i can do this. I searched it and got following script -

#! /usr/bin/ksh
HOST='W.X.Y.Z'
USER='XXXX'
PASSWD='YYYY'

exec 4>&1
ftp -nv >&4 2>&4 |&

print -p open $HOST
print -p user $USER $PASSWD
print -p cd directory
print -p binary
print -p put ash.txt
print -p bye

wait
exit 0

but still getting error -

test_ftp: line 9: print: command not found
test_ftp: line 10: print: command not found
test_ftp: line 11: print: command not found
test_ftp: line 12: print: command not found
test_ftp: line 13: print: command not found
test_ftp: line 14: print: command not found

Also, i m getting this -
test_ftp: line 8: syntax error near unexpected token `&'
test_ftp: line 8: `ftp -v -n >&4 2>&4 |& '


where there is no space between "|" and "&"

Kindly help me.
Thanks
Ashish

razzera 01-27-2010 07:55 AM

install a package called "ftp-upload" onto your server and then use this bash script and put in in a cron.

Quote:

#!/bin/sh

ftp-upload -h IP -u server --password PASSWORD -b -d / /PLACETOUPLOADFROM/FILETOUPLOAD

echo transfer done

mawad71 05-26-2016 06:59 AM

this issue resolved by this script
 
#!/bin/bash
HOST='your.ftp.site'
USER='remoteusername'
PASSWD='remotepasswd'

ftp -n -v $HOST << EOT
ascii
user $USER $PASSWD
prompt
cd upload
ls -la
bye
EOT

Habitual 05-26-2016 08:34 AM

Something wrong with sftp?
ftp is incredibly insecure.

TB0ne 05-26-2016 09:06 AM

Quote:

Originally Posted by Habitual (Post 5551174)
Something wrong with sftp? ftp is incredibly insecure.

Was wondering the same thing...but since this thread had been closed for SIX YEARS before mawad71 re-opened it (with a script that didn't address the OP's original question), I didn't think it mattered. :)

Habitual 05-26-2016 09:10 AM

Coffee is required.

Thanks T


All times are GMT -5. The time now is 09:48 AM.