find eof, then process


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting find eof, then process
# 1  
Old 12-19-2003
find eof, then process

Newbie question. I want to create a shell script that will only move/copy a file if it's determined that the eof string exists. This is to control files being uploaded via FTP. I don't want to move incomplete files, so my only thought is to check for eof, or compare file size every 15-30 seconds on the same file until size in bytes is the same and then move/copy the file. Some uploads occur over very slow connections, with large file sizes, and can take up to 10 minutes.

Anyone already have something like this? What commands would be best to use to facilitate this?
# 2  
Old 12-19-2003
Re: find eof, then process

Quote:
Originally posted by mfilby
Newbie question. I want to create a shell script that will only move/copy a file if it's determined that the eof string exists. This is to control files being uploaded via FTP. I don't want to move incomplete files, so my only thought is to check for eof, or compare file size every 15-30 seconds on the same file until size in bytes is the same and then move/copy the file. Some uploads occur over very slow connections, with large file sizes, and can take up to 10 minutes.

Anyone already have something like this? What commands would be best to use to facilitate this?
what do you mean EOF (end of file) string?

are you looking for something on the last line of the file?

if you are going the shell route you can use if [`tail -1 $file` eq "some_string" ]; then
........
fi

you might need a double [[ ]] vs the single []
# 3  
Old 12-19-2003
Re: Re: find eof, then process

[QUOTE]Originally posted by Optimus_P
[B]what do you mean EOF (end of file) string?

Specifically, I'm working with pdf files, all of which end with EOF.

cat -v /testfile*.pdf on a complete file contains "EOF" at the end. I want to detect that to know if the file is completely uploaded before any cp/mv command on the same file.

Am I wrong to assume all files have an EOF?
# 4  
Old 12-21-2003
>> Am I wrong to assume all files have an EOF?

Yes, you are.
# 5  
Old 12-21-2003
fpmurphy, could you possibly elaborate on your answer at all? Smilie Smilie
# 6  
Old 12-22-2003
Quote:
Originally posted by oombera
fpmurphy, could you possibly elaborate on your answer at all? Smilie Smilie
I rather liked fpmurphy's answer. But to spell it out...

Do a "tail /etc/passwd", "tail /etc/group", and "tail /etc/hosts". I'll bet that you can quickly locate a file that does not literally have "EOF\n" as the last four characters. Some files are even less than four characters in length. They don't pop out of existence or anything.

So yes, while pdf files end with the string "EOF\n", many files do not.
# 7  
Old 12-22-2003
Guess I read too quickly.. didn't realize the OP was asking literally for a string that says EOF or that PDF files have that string at the end. Thanks, Perderabo. Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Automating an interactive process with EOF string

Hello, I'm running Stockfish chess engine ( Home - Stockfish - Open Source Chess Engine ) CLI on Linux in interactive mode which is working fine. root@ubuntu1950x:~# ./stockfish Stockfish 080218 64 POPCNT by T. Romstad, M. Costalba, J. Kiiski, G. Linscott setoption name Debug Log File... (2 Replies)
Discussion started by: prvnrk
2 Replies

2. Shell Programming and Scripting

Can't find string terminator "`" anywhere before EOF

// AIX 6.1 What I am trying to accomplish is to display the user name and the last login date and time in one line: for usrlist in $(cat alluser.txt) do $usrlist perl -e 'print scalar localtime `lsuser -a time_last_login $usrlist | awk -F '=' '{print $2}'`' done However, it... (8 Replies)
Discussion started by: Daniel Gate
8 Replies

3. Programming

Find parent process (not process ID)

Hi: I have a program written in FORTRAN running on AIX platform. It is because missing of documentation and without root password, therefore we want to modify the program so that we can find out which script/program that call this FORTRAN program. I have google for few days, all of them are... (3 Replies)
Discussion started by: cstsang
3 Replies

4. Solaris

Cant find Unix process with ps -ef

Hi All, Heres a little background. We have essbase installed on a solaris server. We are running a report script. The script starts and runs ok.. 1. after some time if i do the ps -ef i can see the process, and it generally completes successfully. 2. Most of the times, when i do the ps with... (2 Replies)
Discussion started by: noufalshaw
2 Replies

5. Shell Programming and Scripting

confused with << EOF EOF

Hi friends , I am confused with << EOF EOF Most of the cases I found sqlplus $db_conn_str << EOF some sql staments EOF another exapmle is #!/bin/sh echo -n 'what is the value? ' read value sed 's/XXX/'$value'/' <<EOF The value is XXX EOF (1 Reply)
Discussion started by: imipsita.rath
1 Replies

6. Programming

How to find if a process a daemon ?

I have a scenario where I need to find if a process is a daemon process or not. This check needs to be done from within the process. I know there are no direct API's to do so. I have explored these options. 1. ctermid() - this can be unsuccessful as per the man pages 2. int devtty; if ((devtty... (7 Replies)
Discussion started by: vino
7 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. AIX

find file with process ID

hello I have a process ID and i want to known what files are use with this process. fuser give to me the process with a file...i search a similar command but the reverse: to know the files with a process thank you (1 Reply)
Discussion started by: pascalbout
1 Replies

9. Solaris

How to find which process is using up too much CPU

Hi, I need to find which processes are hogging the cpu up. please advise. Thanks (1 Reply)
Discussion started by: 0ktalmagik
1 Replies

10. Shell Programming and Scripting

how to find the chid process id from given parent process id

how to find the chid process id from given parent process id.... (the chid process doesnot have sub processes inturn) (3 Replies)
Discussion started by: guhas
3 Replies
Login or Register to Ask a Question