Solved

Checking if file exists using WinSCP

Posted on 2015-01-29
7
1,009 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 55

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 55

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

Turn Insights into Action

Communication across every corner of your business is essential to increase the velocity of your application delivery and support pipeline. Automate, standardize, and contextualize your communication processes with xMatters.

Question has a verified solution.

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

Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

695 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