[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1916
  • Last Modified:

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

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
slobstar
Asked:
slobstar
2 Solutions
 
TintinCommented:
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
 
ITcrowCommented:
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 Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now