Check EOF in shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Check EOF in shell script
# 1  
Old 07-19-2007
Check EOF in shell script

Hi,

I need to check whether one file has EOF or not.

There's one daemon in our system, which will pick the files FTPed to us. However, sometimes the daemon picks the file before FTP is finished.
So I'm planning to add some checking of EOF on the FTPed files in the shell script.

Could anyone please kindly help me on this? SmilieMy boss is chasing me on that...Smilie

Thanks
Will
# 2  
Old 07-19-2007
Unix does not have an EOF char, such as DOS has or had. Some implementations of FTP change the permissions on the destination file when completed. Some use the name <filename>.filepart as the end of the file and then change to to what the filename actually is upon completion.

Couple of ways to check for completion -

Have your daemon wait 60 seconds (sleep) and see if the file changes size during that time.

The best way to handle is to have the transmitter send a separate file (ie filename.end) upon completion - and wait for that.

So many choices....
# 3  
Old 07-19-2007
If you have the utility lsof, then it may be helpful.

You can either lsof filename or lsof -p <pid> where pid is the process id of the ftp process.

See man lsof for more details.
# 4  
Old 07-19-2007
Awk, thank you for your reply.

The issue is we cannot change anything from transmitter side. It sends more than 150k files everyday, and the files received by my server is just around 1%. We can't change the script on transmitter, as it will have big impact...

Our daemon does have 10 sec sleep after it's successful running. But checking size of each file twice will also cost a lot...

Is there any idea that can be suiltable for my scenario..

Thanks
# 5  
Old 07-19-2007
Quote:
Originally Posted by vino
If you have the utility lsof, then it may be helpful.

You can either lsof filename or lsof -p <pid> where pid is the process id of the ftp process.

See man lsof for more details.
Thank you for your suggestion. It's a good idea indeed. However, there's no lsof on our serverSmilie and I'm not authorized to install itSmilie

Thanks
# 6  
Old 07-20-2007
Any other good idea, please..
# 7  
Old 07-20-2007
to summarize -

You cannot change the transmittal side to send anything special

You don't have lsof and no plans to get it.

You think it "costs too much" [in what, processor time???] to check the filesize to see it is not changing. [Guess what a human operator will cost to check it]

The filename doesn't change to indicate completion.

Can't think of anything else

Assuming there is nothing special about the end of the file (sometimes the last record contains all 9's - that you could check for), you are out of luck.

Suggest the human intervention solution - sometimes that works wonders on what they won't do.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash shell script to check if script itself is running

hi guys we've had nagios spewing false alarm (for the umpteenth time) and finally the customer had enough so they're starting to question nagios. we had the check interval increased from 5 minutes to 2 minutes, but that's just temporary solution. I'm thinking of implementing a script on the... (8 Replies)
Discussion started by: hedkandi
8 Replies

2. UNIX for Dummies Questions & Answers

multiple if conditions and EOF in a shell script

I want to create an IF condition with multiple condition, in the statement below I want to add OR EOF, can any one please advise how to do. if } != $sample ] && ; then echo ..... fi code tags please (1 Reply)
Discussion started by: analyst
1 Replies

3. Shell Programming and Scripting

Need EOF usage in shell scripting

Hi all, Can any one explain the usage of EOF in shell scripting?? Gone through some examples from google, but it is not clear... Examples are: 1. $ tr << EOF > abcd > efgh > iojk > EOF O/P is: ABCD EFGH IOJK 2. echo << EOF (1 Reply)
Discussion started by: divya bandipotu
1 Replies

4. Shell Programming and Scripting

Oracle Shell script | here document `EOF' unclosed

Hi folks I m creating script which is give me below error. $ ./function.ksh ./function.ksh: here document `EOF' unclosed Inside the script is #!/bin/ksh export ORACLE_SID=OECDV1 export ORACLE_HOME=/u01/app/oracle/product/10.2.0 export PATH=$ORACLE_HOME/bin:$PATH echo "sql is... (3 Replies)
Discussion started by: tapia
3 Replies

5. UNIX for Advanced & Expert Users

Check EOF char in Unix. OR To check file has been received completely from a remote system

Advance Thanks. (1) I would like to know any unix/Linux command to check EOF char in a file. (2) Or Any way I can check a file has been reached completely at machine B from machine A. Note that machine A ftp/scp the file to machine B at unknown time. (5 Replies)
Discussion started by: alexalex1
5 Replies

6. Shell Programming and Scripting

perl script to check if empty files are created and delete them and run a shell script

I have a local linux machine in which the files are dumped by a remote ubuntu server. If the process in remote server has any problem then empty files are created in local machine. Is there any way using perl script to check if the empty files are being created and delete them and then run a shell... (2 Replies)
Discussion started by: hussa1n
2 Replies

7. Shell Programming and Scripting

How to find EOF character in a Shell ?

Hi, I'm need to determine if a file contains the EOF character, how can I do that in Shell scripting? Regards. (1 Reply)
Discussion started by: jfortes
1 Replies

8. Shell Programming and Scripting

check my first shell script

I have written the below script to determine whether a string is palindrome or not ? But its not working, any help to debug it ? I am new to this forum but when I searched for my question, I found that many people refused to answer this question thinking that its Homework question, Therefore I... (2 Replies)
Discussion started by: gridview
2 Replies

9. Shell Programming and Scripting

check in unix shell script so that no one is able to run the script manually

I want to create an automated script which is called by another maually executed script. The condition is that the no one should be able to manually execute the automated script. The automated script can be on the same machine or it can be on a remote machine. Can any one suggest a check in the... (1 Reply)
Discussion started by: adi_bang76
1 Replies

10. Shell Programming and Scripting

How to check if the file DOES NOT have EOF

Hi, Please help me on this. how to check if the file DOES NOT have EOF ?? I am using ksh for this. (3 Replies)
Discussion started by: BasavarajaKC
3 Replies
Login or Register to Ask a Question