Solved

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

Posted on 2004-10-15
2
1,904 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
[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 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

Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

Question has a verified solution.

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

Introduction:   Welcome to my first article ever. To begin with, the reason I write this article.  I participated in a question on Experts Exchange about the start command in Windows and there were some discussion about the usage. The discussio…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
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…

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