[ale] FTP files

Jim Kinney jim.kinney at gmail.com
Tue Jan 22 12:35:30 EST 2013


The heredoc format of the ftp line looks wrong. also, you are iterating
over a list of files and creating a new ftp connection for each file.
Instead use:

mytemp=$(mktemp -d)
mylog=$(mktemp)
cp $(cat /chroot/home/fl/fl_sdirc/files.txt) ${mytemp}
cd ${mytemp}
ftp -i <host> 2>$1>${mylog} << EOF
user <name> <passwd>
binary
cd <remote path to file location>
mput *
exit
EOF

On Tue, Jan 22, 2013 at 12:18 PM, Chuck Payne <terrorpup at gmail.com> wrote:

> Guys,
>
> Ok, I think I have a better script, but I am having a problem with the
> for/loop with ftp'ing files, looks like it breaking at the <<+
>
> Here is my new script
>
> ========================Begin Script=================================
>
> #!/bin/bash
> # ftp script
> # by Chuck Payne
> # ftp, logs, and moves files
>
> LOG=$(/var/log/fl_sdirc)
> FILES=$(cat /chroot/home/fl/fl_sdirc/files.txt | wc -l)
> TIME=$(`date '+%m-%d-%Y %H:%M'`)
> FILE=$(/chroot/home/fl/fl_sdirc/files.txt)
>
>
> if [ -e $FILE ] ; then
>   rm -f $FILE
> fi
>
> ls /chroot/home/fl/fl_sdirc >> /chroot/home/fl/fl_sdirc/files.txt
>
> if [ $FILE=="0"] ; then
>   echo "$TIME" >> $LOG
>   echo "No Files tranfer" >> $LOG
> else
>
> for i in `cat /chroot/home/fl/fl_sdirc/files.txt` ; do
>   ftp -n 192.168.105.29 <<+
>   user flsdir essex
>   binary
>   put $i
>   quit ;
> done
>
> echo "$TIME" >> $LOG
> echo "File following file were transfer to Pawnee" >> $LOG
>
> for i in `cat /chroot/home/fl/fl_sdirc/files.txt` ; do
>   echo "$i" >> $LOG
> done
>
> for i in `cat /chroot/home/fl/fl_sdirc/files.txt` ;
>   mv $i /home/fl_sdirc/$i.$TIME ;
> done
>
> fi
>
>
>
> ========================End Script==================================
>
>
> --
> Terror PUP a.k.a
> Chuck "PUP" Payne
>
> (678) 636-9678
> -----------------------------------------
> Discover it! Enjoy it! Share it! openSUSE Linux.
> -----------------------------------------
> openSUSE -- en.opensuse.org/User:Terrorpup
> openSUSE Ambassador/openSUSE Member
> Community Manager -- Southeast Linux Foundation (SELF)
> skype,twiiter,identica,friendfeed -- terrorpup
> freenode(irc) --terrorpup/lupinstein
> Register Linux Userid: 155363
>
> Have you tried SUSE Studio? Need to create a Live CD,  an app you want
> to package and distribute , or create your own linux distro. Give SUSE
> Studio a try. www.susestudio.com.
> See you at Southeast Linux Fest, June 7-9, 2013 in Charlotte, NC.
> www.southeastlinuxfest.org
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
>



-- 
-- 
James P. Kinney III
*
*Every time you stop a school, you will have to build a jail. What you gain
at one end you lose at the other. It's like feeding a dog on his own tail.
It won't fatten the dog.
- Speech 11/23/1900 Mark Twain
*
http://electjimkinney.org
http://heretothereideas.blogspot.com/
*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.ale.org/pipermail/ale/attachments/20130122/05e411ac/attachment-0001.html>


More information about the Ale mailing list