Identifying presence and name of new file(s)?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Identifying presence and name of new file(s)?
# 1  
Old 03-25-2013
Identifying presence and name of new file(s)?

I have an HP-UX server that runs a script each night. The script connects to an SFTP server and downloads all xml files (if any are present) from a certain folder, and then deletes the files from the SFTP server. So sometimes it will download a new file, sometimes it will download 2 or 3 new files, and sometimes it will download zero new files.

The files are all downloaded to a folder on my server that contains dozens of other similar files.

If/when a new file gets downloaded, I need to run other scripts against it, to processes the data. I'm doing it manually right now. Does anyone know of a better way to identify 1. Whether or not any new files are present. 2. What the file name is of the new files.

My thought is to capture the output of "ls", then run the sftp download script, then capture the output of "ls" again, and run a diff on the two. That seems a little clunky though, there must be a cleaner way.

Any ideas are appreciated!

Last edited by lupin..the..3rd; 03-25-2013 at 05:15 PM..
# 2  
Old 03-25-2013
Quote:
Originally Posted by lupin..the..3rd
That seems a little clunky though, there must be a cleaner way.

Any ideas are appreciated!
Why not just drop the files in an initially empty directory?

Regards,
Alister
# 3  
Old 03-25-2013
Code:
find /my/folder -ls | grep "`date +'%b %d'`" | grep xml | cut -c 69-

FYI I cobbled something together. This looks like it'll give me what I need. It will list the xml files in the directory that have today's date on them.

Last edited by lupin..the..3rd; 03-25-2013 at 05:17 PM..
# 4  
Old 03-25-2013
Wouldn't the time stamps reflect the download time? And, I'm not sure if verbosity can be increased so you can capture a complete transfer log.
# 5  
Old 03-25-2013
Quote:
Originally Posted by RudiC
Wouldn't the time stamps reflect the download time? And, I'm not sure if verbosity can be increased so you can capture a complete transfer log.
Correct. Time stamps reflect the download time. So if no new files are downloaded, it will be an empty list. If 3 new files are downloaded, it will return the names of those 3 files. Exactly what I need. Files are downloaded at 3 am. The processing script runs at 7:30 am. So any new files present will have the current date.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Identifying missing file dates

Hi Experts, I have written the below script to check the missing files based on the date in the file name from current date to in a given interval of days. In the file names we have dates along with some name. ex:jera_sit_2017-04-25-150325.txt. The below script is working fine if we have only... (10 Replies)
Discussion started by: nalu
10 Replies

2. Shell Programming and Scripting

Check file presence and delete other file

Hello, I have file all_file.txt at the end of process this file all_file.txt should be deleted only if there is no file present in dir /all_file/tmp/ or in it's sub directory. can you please help me with the peace of code for this. Thanks (2 Replies)
Discussion started by: kumar30213
2 Replies

3. Shell Programming and Scripting

Check presence of trigger file

Hi, I make a sftp connection successfully.My requirement is the script shall execute only after i find a trigger file(dailyreport.OK.psv) in the remote dir. If the trigger file is not present ,the script should exit else it should continue with the rest of the scripts statements. Below code is... (13 Replies)
Discussion started by: samrat dutta
13 Replies

4. Shell Programming and Scripting

Check the presence of file >size?

Hi, Following script work fine: #!/bin/bash FILE=$1 if ; then echo Yay else echo Boo fi But I would like to add another condition that if FILE... (3 Replies)
Discussion started by: nrjrasaxena
3 Replies

5. Shell Programming and Scripting

Identifying the file completion

Hi, A script is running for multiple databases so data is also being populated for multiple DBs in a.txt file. I need to rename this file once all the data is populated. Kindly suggest me How can I check once file is populated completely before renaming? Thanks in advance. (3 Replies)
Discussion started by: ravigupta2u
3 Replies

6. Shell Programming and Scripting

check file for presence of set of strings

hi everybody, I need a quick help with this issue. I have configuration file in which the following set of strings must be present. I need to check it with the bash script (leading spaces are not significant). Check must be case insensitive. Can anybody help? ... any lines <SECTION... (4 Replies)
Discussion started by: sameucho
4 Replies

7. Shell Programming and Scripting

check presence of input file

My script is taking a file "input.in" as input for running the script. My worry is that i need to execute the script only if the file is present, if it's not don't perform the next commands. Just to have a check at the beginning of the script : If "input.in" exists, then go on. If it's does not... (4 Replies)
Discussion started by: newpromo
4 Replies

8. Shell Programming and Scripting

Polling continously for presence of a file

Hi, My os is sun solaris 5.10 and Korn shell scripting. I have a file name like CCNA_EARLY_SWP.w062309 where 062309 is date in mmddyy .This is the value date of the file.(will I need to check continously from 5.00 - 7.00 am daily for this file . If the file has not come at 5 am or 7am... (4 Replies)
Discussion started by: manoj39
4 Replies

9. Shell Programming and Scripting

identifying null values in a file

I have a huge file with 20 fileds in each record and each field is seperated by "|". If i want to get all the reocrds that have 18th or for that matter any filed as null how can i do it? Please let me know (3 Replies)
Discussion started by: dsravan
3 Replies

10. UNIX for Dummies Questions & Answers

How do I test for the presence of a file in Bourne Shell

How do I test for the presence of a file in Bourne Shell (3 Replies)
Discussion started by: vins
3 Replies
Login or Register to Ask a Question