Solved

Perl script to check for whether Remote files exist

Posted on 2008-06-24
4
1,243 Views
Last Modified: 2008-06-24
How can I use perl to see whether or not a remote file exists or not?  
I need to check to see if a file is available on a unc path \\host\file1 and handle the exception if it is not accessible.

Thanks
0
Comment
Question by:TyBay
  • 2
4 Comments
 
LVL 39

Accepted Solution

by:
Adam314 earned 500 total points
ID: 21860156

if(-e "\\\\host\\file1") {

    print "file exists\n";

}

else {

    print "File does not exist\n";

}

Open in new window

0
 
LVL 14

Expert Comment

by:agriesser
ID: 21860184
What platform are you running this script on? Windows or Linux?
0
 

Author Comment

by:TyBay
ID: 21861567
Windows
With Adam's pattern it does not seem to recognize that the file exists.  I can access via unc and then when using the provided pattern in Active State Perl on Windows I get a false negative every time.
0
 

Author Comment

by:TyBay
ID: 21861614
scratch that - syntax error on my part...
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

743 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

13 Experts available now in Live!

Get 1:1 Help Now