Solved

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

Posted on 2004-10-15
2
1,890 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
ID: 12322843
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
ID: 12330528
Use File::Remote

Module documentation have plenty of functional examples:
http://search.cpan.org/~nwiger/File-Remote-1.16/Remote.pm
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
The viewer will learn how to dynamically set the form action using jQuery.

789 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