The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
check if remote file exists hcclnoodles Shell Programming and Scripting 2 08-27-2008 05:53 PM
check if file exists in a mounted windows shared folder jul Shell Programming and Scripting 2 05-14-2008 01:50 AM
Check File Exists and compare to previous day file script rbknisely Shell Programming and Scripting 3 02-07-2008 11:53 AM
check if file exists on remote system ? hcclnoodles Shell Programming and Scripting 2 10-26-2006 04:08 AM
check if exists a .ZIP file and unzip it using ftp DebianJ Shell Programming and Scripting 1 05-05-2005 04:46 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-17-2003
methos methos is offline
Registered User
  
 

Join Date: Jan 2002
Posts: 18
Post perl ftp check file exists

I have a perl script that ftp's to an NT server, checks if the file is growing, gets the file, does some more size checking after the get on the unix box. My question, is there a good way to check if the file exists on the NT when I know the exact file to check for? I thought about doing an "ls file.dat" and passing the return code to a variable and then checking the varible, but that seems kinda messay. Thanks in advance for any suggestions.
  #2 (permalink)  
Old 06-18-2003
WIntellect's Avatar
WIntellect WIntellect is offline
Registered User
  
 

Join Date: Sep 2002
Location: United Kingdom
Posts: 170
You could try something like this:
Code:
if (-f 'c:\\location_to_file\\filename') {
        # code necessary
}
you MUST use double "\" (e.g. "\\") to symbolise a single "\" - only 'cos it's on a Windows computer

me likes Perl
  #3 (permalink)  
Old 06-18-2003
methos methos is offline
Registered User
  
 

Join Date: Jan 2002
Posts: 18
Thanks for the info. I came up with this as I continued to pound away at it.

next if (($fsize = $ftp->size($ntfile)) == undef);

I have to check the file size anyway, if the file does not exists return value of size is undefined. The "next" is used to take me back to the previous loop before executing any commands that may follow this statement.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:28 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0