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
get latest file inquirer Shell Programming and Scripting 4 04-02-2009 12:15 PM
Getting latest file from ftp arunavlp UNIX for Dummies Questions & Answers 3 02-08-2008 10:19 AM
script to find latest executable in particular directory and start that particular ex kvineeth Shell Programming and Scripting 6 09-24-2007 08:19 AM
Unix shell scripting to find latest file having timestamp embedded... kaushik25 AIX 2 08-06-2007 11:42 PM
Reading file names from a file and executing the relative file from shell script anushilrai Shell Programming and Scripting 4 03-10-2006 05:25 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-22-2007
im_new im_new is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 15
Shell script to ftp latest file

Hello All,
Hope u r doing fine.
I'm writing a shell script to ftp the latest file having pericular convention as 'ULTI_15072007043205.txt' on daily basis.
Now the date & timing of the file geleration isnt constant, so the file name daily varies as per the date & timing of generation.
Can anyone advice me how I can tackle with this?

Shilpa
  #2 (permalink)  
Old 11-22-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
You use could 'ls' to return you the names sorted by date.

Quote:
Originally Posted by NetBSD
-t Sort by time modified (most recently modified first) before sorting the operands by lexicographical order.
then use the first one.
  #3 (permalink)  
Old 11-22-2007
uvrakesh uvrakesh is offline
Registered User
  
 

Join Date: Dec 2005
Posts: 78
atomated ftp script, modify as per your request

#! /bin/sh
#Do an ftp and get the list of filenames starting with ULT
ftp -ivn hostname <<INPUT >& out
user rakesh Welcome
ls ULT*
bye
INPUT

#Obtain the latest filename inside the variable filename using sort command
filename=`awk '{if($NF ~ "ULT") {print $NF}}' out | sort -r | sed -ne '1p'`


#Do ftp again and get the desired file
ftp -ivn hostname <<INPUT >& out
user rakesh Welcome
get $filename
  #4 (permalink)  
Old 11-22-2007
uvrakesh uvrakesh is offline
Registered User
  
 

Join Date: Dec 2005
Posts: 78
the ls executed on ftp is different from our full fledged ls
  #5 (permalink)  
Old 11-22-2007
Cameron's Avatar
Cameron Cameron is offline Forum Advisor  
Registered User
  
 

Join Date: Nov 2001
Location: Brisbane, Australia
Posts: 500
My suggestion reading your query ...

REQUIRED_FILETYPE=UTIL_
...
cd ${DESIRED_DIR}
FILE=`ls -t ${REQUIRED_FILETYPE}* | sed '1q'`
echo ${FILE}
...
Then perform your outbound FTP.


Hope that helps.

Cheers,
Cameron
  #6 (permalink)  
Old 11-22-2007
im_new im_new is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 15
Thanks a lot to all, this really has helped a lot.....

Shilpa
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 02:32 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