Solved

Checking if file exists using WinSCP

Posted on 2015-01-29
7
683 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
Comment Utility
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
Comment Utility
Do you know how I can check if the file exists?
0
 
LVL 43

Expert Comment

by:Steve Knight
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 51

Expert Comment

by:Bill Prew
Comment Utility
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
Comment Utility
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 51

Accepted Solution

by:
Bill Prew earned 500 total points
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Storage devices are generally used to save the data or sometime transfer the data from one computer system to another system. However, sometimes user accidentally erased their important data from the Storage devices. Users have to know how data reco…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now