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 > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Transfering files from windows to unix box through sftp Amey Joshi Shell Programming and Scripting 3 07-30-2009 05:54 AM
How to Check Whether Core File complete or truncated khan_069 HP-UX 1 05-05-2006 07:59 PM
How to Check Whether Core File complete or truncated khan_069 AIX 2 04-22-2006 04:28 AM
some process writin file - check if complete sade Filesystems, Disks and Memory 0 09-26-2003 08:46 AM

Reply
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 08-09-2009
srineel srineel is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 2
Exclamation SFTP script - poll every min to check file complete before transfering

Hello,

Before I do a GET remote file, I need to ensure the remote file is a complete file i.e. whatever process is saving the file to the remote folder should complete the transfer before I go GET it through my script.

So I'm thinking I need to poll the remote file every minute or so to check the file size and if between 2 polls if the file size is same then go ahead and GET the file.

I'm struggling as as this polling needs to be done on the remote folder and
!sleep command does not work in sftp . Any help really appreciated.

Thanks - Neel
  #2 (permalink)  
Old 08-09-2009
sandholm sandholm is offline
Registered User
  
 

Join Date: Dec 2007
Location: New Hampshire
Posts: 20
If you're using Linux, then check out inotify.
See this: Filesystem Monitoring ?(Tom's Linux Tip's)?
  #3 (permalink)  
Old 08-09-2009
srineel srineel is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 2
SFTP script

Actually I'm on AIX. Here's a general algorithm on what i'm trying to do.

first_time = true
while /usr/bin/true
do
if first_time ()
ftp get file,
name it as file_1
first_time=false
sleep 100
else
get file, name it as file_2
file_2_size =ls -l | tr -s " " | cut -d" " -f5
file_1_size =ls -l | tr -s " " | cut -d" " -f5
if file_2_size == file_1_size
then
exit loop
else (if file_2.size > file_1.size then
copy file_1 = file_2
sleep 100
fi
fi
done

I guess I need this transalated to unix format. Thanks for the help.

-Neel

---------- Post updated at 12:15 PM ---------- Previous update was at 12:11 PM ----------

Actually this is a second option, if somehow I can do the sleep on the remote server and check the file sizes (before and after) then that should be better than downloading the files to the client and doing the compare.

Thanks -Neel
  #4 (permalink)  
Old 08-09-2009
sparcguy sparcguy is offline Forum Advisor  
Registered User
  
 

Join Date: Nov 2006
Posts: 315
How does your polling script that check the file on one server know how to tell the ftp script on another server that the file is ok for transfer?

If you are using control-m it's possible, you can have script in Beijing run the file check and when it completes have it pass the control to another ftp script in Malaysia and trigger it. But for normal shell script how you going to do that?

A better solution will be to have 1 script instead of 2. 1 script on the server with the file. The script will do checking then after checking complete the same script will ftp using PUT instead, that way you have better control over the checking.
  #5 (permalink)  
Old 08-09-2009
jim mcnamara jim mcnamara is online now Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,716
rsync - if you can install it - will handle all of those issues. It is designed to copy files using ssh transport (like sftp) and keep the transferred files in sync with the current version of the remote file.
Sponsored Links
Reply

Bookmarks

Tags
ftp, sftp, unix

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 06:43 AM.


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