Solved

How do I check if a file exist on a remote server in PERL?

Posted on 2004-10-15
2
1,880 Views
Last Modified: 2013-12-25
How do I check if a file exist on a remote server?

I use this to check if a file exist on the local machine

$filename= "products/images/file.txt";
if(-e $image_url){
  # do something
}

is there a similar way of doing it or...
0
Comment
Question by:slobstar
2 Comments
 
LVL 48

Accepted Solution

by:
Tintin earned 400 total points
Comment Utility
First you have to answer what protocol, ie:  HTTP, HTTPS, SSH, FTP, SOAP etc.

I'll take a guess at HTTP, in which case, do

use LWP::Simple;
head("http://www.example.com/some/file.txt") or die "file.txt does not exist on remote server\n";
 


0
 
LVL 5

Assisted Solution

by:ITcrow
ITcrow earned 100 total points
Comment Utility
Use File::Remote

Module documentation have plenty of functional examples:
http://search.cpan.org/~nwiger/File-Remote-1.16/Remote.pm
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

Ever wondered how to display how many visitors you have online. In this tutorial I will show you an easy but effective way to display the number of online visitors in WhizBase. In this article I assume you have read my previous articles and know …
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

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

10 Experts available now in Live!

Get 1:1 Help Now