Solved

Checking if file exists using WinSCP

Posted on 2015-01-29
7
798 Views
Last Modified: 2015-02-18
I need to check if the EXTRmmDD.ZIP exists on the SFTP.

If it does, than put it in the C:\ziptest folder.

If it does not exist exit successfully.

I have attached my script that currently pulls the file down successfully if it already exists on the SFTP.
CheckIfFileExistsWINSCP.txt
0
Comment
Question by:flagshipcredit
  • 2
  • 2
  • 2
7 Comments
 
LVL 43

Expert Comment

by:Steve Knight
ID: 40577893
on phone so will look back later... you may want to simplify your yesterday getting routine to two lines.  See some examples in my article here:

Will look back from pc later if I can.
http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_1153-Using-dates-in-batch-files-scripts.html Steve
0
 

Author Comment

by:flagshipcredit
ID: 40586188
Do you know how I can check if the file exists?
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 40586806
Off hand I don't sorry.  The easiest way IMO would be to make it download into a known empty directory, then if a file exists in there it is the one you want.  If no file exists then it didn't need to run?  Is that a suitable option?
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 53

Expert Comment

by:Bill Prew
ID: 40615766
Slightly confused.  AS it stands, wouldn't you get the results you want.  WINSCP will try and transfer the file you are specifying, and if it exists will xfer it.  If it doesn't exist I expect WINSCP will error, but will not transfer any file.  Isn't that the result you wanted?

~bp
0
 

Author Comment

by:flagshipcredit
ID: 40616567
I need the file to check every 5 minutes. I do not want to get an email every 5 minutes saying the job failed.
0
 
LVL 53

Accepted Solution

by:
Bill Prew earned 500 total points
ID: 40616590
Okay, in that case I think it will be a two step process.  First, use WINSCP to do a listing of the files available in the FTP server location, and save that list to your local PC.  Then process the list file and see if the file you want is in there.  If it is do a second step to actually download it.

If you need help with those WINSCP commands and the support BAT script let me know I can try to put something together.

~bp
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Viber-Only Restriction 6 43
Network connections wi-fi configuration issue 6 30
Network access 4 37
ISP Change 14 49
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
Most of the applications these days are on Cloud. Cloud is ubiquitous with many service providers in the market. Since it has many benefits such as cost reduction, software updates, remote access, disaster recovery and much more.
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question