PC Review


Reply
Thread Tools Rate Thread

Automatically downloading files daily by psftp

 
 
Raven
Guest
Posts: n/a
 
      23rd Jan 2006
Hi,

I am modifying my previous written batch file(though I am an amateur)
which can daily download a list of log files from a list of sftp
servers, which generates the logs daily. Since the previous script only
downloads ALL the files at night, which may cause certain problems as
the number of file in the servers get larger. I wish to write a batch
file that can get files generated yesterday (please note that log
filename follows the YYYYMMDD convention).

My previous operation is that I have a batch file which lists the
server and run psftp with another cmd for the software. My trouble now
is that the psftp seems not to support local system variable in their
wildcard.
(if yes, I can simply wirite psftp (E-Mail Removed)....
cd ....
mget .../.../*%Dayvar%*)

previous operation:
Batch file(contain of list of server ips; psftp is called here) ->
psftp command file (contain the operation command for psftp)
end


So now I am thinking of another method. Could I generate one text file
by batch daily automatically before the downloading start which I can
specify the date. After psftp is fed with this file when it is called
by the batch file, it can seamlessly download all files in the server
whose names bear, say, 12?)

so my proposed operation:
batch file(generate a command file based on local system date for psftp
before the downloading start)->
batch file(contain of list of server ips; psftp is called here with the
newly created command file)
psftp does its job by running the newly created file
done

Thanks very much. And if you do know anyway of doing so, please let me
know.

 
Reply With Quote
 
 
 
 
foxidrive
Guest
Posts: n/a
 
      23rd Jan 2006
On 22 Jan 2006 18:56:26 -0800, Raven wrote:

> So now I am thinking of another method. Could I generate one text file
> by batch daily automatically before the downloading start which I can
> specify the date. After psftp is fed with this file when it is called
> by the batch file, it can seamlessly download all files in the server
> whose names bear, say, 12?)


Using WSH to get yesterday's date (see below) and echoing the commands to a
script file, to pass on to PSFTP (which I know nothing about).

> so my proposed operation:
> batch file(generate a command file based on local system date for psftp
> before the downloading start)->
> batch file(contain of list of server ips; psftp is called here with the
> newly created command file)
> psftp does its job by running the newly created file
> done


This code will get you yesterdays date in YYYYMMDD format.

@echo off
:: from code by Phil Robyn
setlocal
set date1=today
set qty=-1
if /i "%date1%" EQU "TODAY" (
set date1=now
) else (
set date1="%date1%"
)
echo >"%temp%\%~n0.vbs" s=DateAdd("d",%qty%,%date1%)
echo>>"%temp%\%~n0.vbs" WScript.Echo year(s)^&_
echo>>"%temp%\%~n0.vbs" right(100+month(s),2)^&_
echo>>"%temp%\%~n0.vbs" right(100+day(s),2)
for /f %%a in (
'cscript //nologo "%temp%\%~n0.vbs"') do set result=%%a
del "%temp%\%~n0.vbs"
endlocal& set day=%result:~0,4%%result:~4,2%%result:~6,2%
echo %%day%% is set to "%day%" (without the quotes)
 
Reply With Quote
 
Raven
Guest
Posts: n/a
 
      23rd Jan 2006
thx for the code!

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Downloading big datasets daily? =?Utf-8?B?bWFydWxv?= Microsoft Excel Programming 2 30th Oct 2005 09:13 PM
Internet explorer opens files automatically instead of downloading Syd Windows XP Internet Explorer 5 14th Jun 2004 02:38 AM
Backup files daily automatically? Vincent Valle Windows XP Customization 4 27th Jan 2004 07:14 PM
How do i stop automatically downloading files Tony Windows XP Customization 3 19th Oct 2003 05:33 PM
IE downloading and opening files automatically! Ron Windows XP Internet Explorer 2 14th Jul 2003 09:52 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:11 AM.