Page 1 of 1

windows ftp.exe

Posted: Tue 30 Aug 2011 2:49 pm
by n9mfk
Hi All,
what wood the best command to use to upload a folder like the report
beau

Re: windows ftp.exe

Posted: Wed 31 Aug 2011 5:23 pm
by neondesertweather
Hi beau,

Assuming you're using Windows a good program to use is MOVEit Freely from ipswitch http://www.ipswitchft.com/products/move ... index.aspx
It's a command line utility and is a great replacement for the built in FTP command.

It's fairly well documented and easy to use. After installation, I created a batch file that contains the following commands:

Code: Select all

@echo off
ftps -a -s:report.ftp
The -a switch starts the program in passive mode.
The -s:filename tells the program to read a script from a file, in this case report.ftp

report.ftp is located in my C:\Cumulus\Reports subdirectory and contains these commands:

Code: Select all

open yourwebsite.com
yourFtpUserName
yourFtpPassword
cd www/NOAA-reports
put NOAAMO0811.txt
put NOAAYR2011.txt
quit
Most of this is self explanatory. The cd command is used to change directories to the one you want your report files in.

I then use Windows task manager to run the batch file at 12:05am every day after Cumulus has updated the reports.

Hope this helps! :)

Re: windows ftp.exe

Posted: Wed 31 Aug 2011 5:46 pm
by n9mfk
Hi Larry,

I was hoping to find a way around changing it every month

Code: Select all

put NOAAMO0811.txt
beau

Re: windows ftp.exe

Posted: Wed 31 Aug 2011 6:22 pm
by steve
You need an 'ftp sync' utility so it just checks what files are on your PC and what are uploaded, and keeps the web site up to date.

Re: windows ftp.exe

Posted: Wed 31 Aug 2011 6:33 pm
by steve

Re: windows ftp.exe

Posted: Wed 31 Aug 2011 6:45 pm
by mcrossley
well you could create the script file dynamically...

Code: Select all

@echo off
echo open yourwebsite.com > temp.ftp
echo yourFtpUserName >> temp.ftp
echo yourFtpPassword >> temp.ftp
echo cd www/NOAA-reports >> temp.ftp
echo put NOAAMO%date:~-7,2%%date:~-2,2%.txt >> temp.ftp
echo put NOAAYR%date:~-4,4%.txt >> temp.ftp
echo quit >> temp.ftp
ftps -a -s:temp.ftp
del temp.ftp
Completely untested by the way! And assumes a UK date format dd/mm/yyyy in the date variable

Re: windows ftp.exe

Posted: Wed 31 Aug 2011 6:55 pm
by steve
Don't forget that files are created up to the end of the previous day, so on the first of the month the latest monthly report is for the previous month, and on the 1st Jan the yearly report is for the previous year. In other words, you need to subtract a day from the date.

Re: windows ftp.exe

Posted: Wed 31 Aug 2011 8:38 pm
by mcrossley
OK, a different approach then that avoids some horrible batch maths!

Use the file Archive attribute...

Code: Select all

@echo off
echo open yourwebsite.com > temp.ftp
echo yourFtpUserName >> temp.ftp
echo yourFtpPassword >> temp.ftp
echo cd yourWebPath/NOAA-reports >> temp.ftp
for /f "tokens=* delims= " %%a in ('dir /b/a:A NOAA*.txt') do echo put %%~a >> temp.ftp
ftps -a -s:temp.ftp
del temp.ftp
attrib -R NOAA*.txt
Oh how long ago was it we used to write batch scripts - very nostalgic :lol:
Or use a file sync utility :roll:

Re: windows ftp.exe

Posted: Wed 31 Aug 2011 8:57 pm
by n9mfk
Hi Mark,
what is ftp.tmp
also are you using ftp.exe or some other software
thanks beau

Re: windows ftp.exe

Posted: Wed 31 Aug 2011 9:00 pm
by mcrossley
The script is written for the utility that Larry mentioned in the second post on this thread. I'm just tweaking his script so you do not have to edit it every month and year end.

Re: windows ftp.exe

Posted: Wed 31 Aug 2011 11:30 pm
by neondesertweather
mcrossley wrote:OK, a different approach then that avoids some horrible batch maths!

Use the file Archive attribute...

Code: Select all

@echo off
echo open yourwebsite.com > temp.ftp
echo yourFtpUserName >> temp.ftp
echo yourFtpPassword >> temp.ftp
echo cd yourWebPath/NOAA-reports >> temp.ftp
for /f "tokens=* delims= " %%a in ('dir /b/a:A NOAA*.txt') do echo put %%~a >> temp.ftp
ftps -a -s:temp.ftp
del temp.ftp
attrib -R NOAA*.txt
Oh how long ago was it we used to write batch scripts - very nostalgic :lol:
Or use a file sync utility :roll:
It does the trick Mark!
Thanks! 8-)

Re: windows ftp.exe

Posted: Wed 31 Aug 2011 11:46 pm
by n9mfk
Larry,
did you test that with ftps.exe if so were did you find it
thanks

Re: windows ftp.exe

Posted: Thu 01 Sep 2011 1:11 am
by neondesertweather
n9mfk wrote:Larry,
did you test that wit ftps.exe if so were did you find it
thanks
Yes it was with ftps. You can download it here:
http://www.ipswitchft.com/products/move ... index.aspx

Re: windows ftp.exe

Posted: Thu 01 Sep 2011 12:58 pm
by n9mfk
here are some changes this will run out side of the reports folder

Code: Select all

@echo off

pushd "c:\Cumulus\Reports"

echo open yourwebsite.com > temp.ftp
echo yourFtpUserName >> temp.ftp
echo yourFtpPassword >> temp.ftp
echo cd yourWebPath/NOAA-reports >> temp.ftp
for /f "tokens=* delims= " %%a in ('dir /b/a:A NOAA*.txt') do echo put %%~a >> temp.ftp
echo cd .. >> temp.ftp
echo cd data >> temp.ftp
echo put c:\cumulus\data\dayfile.txt >> temp.ftp
ftps -a -s:temp.ftp
del temp.ftp
attrib -R NOAA*.txt

popd

TIMEOUT /T 30


Beau