Wait for file to get copied in server path and then proceed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Wait for file to get copied in server path and then proceed
# 1  
Old 08-27-2014
Code Wait for file to get copied in server path and then proceed

Hi,

I have a requirement to create below script:
  1. Script must run infinitely in background.
  2. It will check a particular type of file to be copied in specific folder of server
  3. Script must wait till any file gets fully copied ..(important) and then
  4. It will read that file

Experts please help me on above queries with good hints of scripts and commands.

Thanks in advance.

Regards,
V kumar

Last edited by rbatte1; 08-27-2014 at 12:20 PM.. Reason: Set as LIST
# 2  
Old 08-27-2014
Welcome Vikash163,
I have a few to questions pose in response first:-
  • Is this homework/assignment? There are specific forums for these.
  • What have you tried so far?
  • What output/errors do you get?
  • What OS and version are you using?
  • What are your preferred tools? (C, shell, perl, awk, etc.)
  • What logical process have you considered? (to help steer us to follow what you are trying to achieve)
  • Would your process have to survive a reboot?
Most importantly, What have you tried so far?

There are probably many ways to achieve most tasks, so giving us an idea of your style and thoughts will help us guide you to an answer most suitable to you so you can adjust it to suit your needs in future.


We're all here to learn and getting the relevant information will help us all.



Robin
# 3  
Old 08-27-2014
How will you determine that the file is fully copied?
# 4  
Old 08-27-2014
Quote:
Originally Posted by RudiC
How will you determine that the file is fully copied?
And that's the crux of this type of problem.

The ONLY way to know a file is fully copied is for the SENDER to generate some kind of signal. Because only the SENDER knows if the file has been sent successfully. The receiver does not have and can not have that information.

Period.

If it's important that the file be fully copied, you can't get around that limitation.
# 5  
Old 08-27-2014
Yes, a broken connection is EOF but not leaving a valid file. The cheapest and very popular trick is to have the sender rename it after transmission from a temp name to the right name. If you see the name, it is good.

Some prefer a flag file to say implicitly that it is OK, or send a length or cksum, md5 output for comparison.

If the sender is not cooperating, you can tell that the local writer closed with UNIX 'fuser'.

If the file has structure, that can tell you it is complete, like a trailer or XML element.

It's the kind of question that sells NDM (now an IBM product) and such.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Checking integrity copied from remote server using UNIX command

I am getting a file (abc.txt) using scp from remote server. scp <connect string> -i $HOME/.ssh/id_dsa rem_id@hostname:/var/prod/abc.txt /var/prod/abc.out Before loading I need to check if the file is indeed same , for that I thought of checking the line count but when I used ssh command it was... (3 Replies)
Discussion started by: lalitpct
3 Replies

2. UNIX for Beginners Questions & Answers

How to access file path from another server?

Hi there, Say I have Server A and B, how do I configure A with path aaa/bbb/ccc to be able to access by Server B with aaa/bbb/ccc/<content> (9 Replies)
Discussion started by: alvinoo
9 Replies

3. Red Hat

Server shutdown- /var/log/messages copied over here

Hi, Please share your thought what could make the server shutdown: Dec 1 10:20:05 powellton syslog-ng: syslog-ng version 1.6.8 starting Dec 1 10:20:06 powellton kdump: Loaded kdump kernel: /sbin/kexec -p /boot/vmlinux-2.6.16.60-0.34-kdump --append="CRASH=1 root=/dev/rootvg/rootlv... (1 Reply)
Discussion started by: admin_db
1 Replies

4. Shell Programming and Scripting

How to get user to choose files to be copied to FTP server?

Hey all. I'm writing a script to automatically login to a router, change directories to where crashfiles are located, then listing all files in that directory. This is where I'm at so far and wish to have some user interaction to choose the files. What I am trying to do is list the files and get... (1 Reply)
Discussion started by: Gouda
1 Replies

5. Red Hat

Files copied to FTP server not shown

I had copied 2 files to an FTP server which I deployed on my RHEL 5.8 server. The ownership I kept for the files are for the user, ftp. But, I do not see the files on the FTP location using either accessing through Windows explorer or the browser. The ftp location is ftp://10.101.17.80/incoming.... (7 Replies)
Discussion started by: RHCE
7 Replies

6. Shell Programming and Scripting

Check files copied from remote server

There is a process which copy files form unix a to unix b I would like to check whether all files copied from a to b or not ,and list which are the missing files. Is there a command to check like that (3 Replies)
Discussion started by: lalitpct
3 Replies

7. Shell Programming and Scripting

preserving the timestamp of a file when copied from remote server to local server using ftp

Hi, I need to copy few files from remote server to local server. I write a shell script to connect to the remote server using ftp and go to that path. Now i need to copy those files in the remote directory to my local server with the timestamp of all those files shouldnt be changed. ... (5 Replies)
Discussion started by: arunkumarmc
5 Replies

8. Solaris

Check copied file

Hi all, If i wanted to copy file within different folders or different servers, how do i determine the copied file is absolutely correct :confused: Is it using cmp and chksum command enough? Anyway that i can make further checking? Thanks in advance for reading & anyone who reply the... (7 Replies)
Discussion started by: beginningDBA
7 Replies

9. Shell Programming and Scripting

Need to execute 2 scripts, wait, execute 2 more wait, till end of file

:cool: I need to execute a shell script to do the following: cat a file run two back ground processes using the first two values from the file wait till those background processes finish run two more background processes using the next two values from the file wait till those background... (1 Reply)
Discussion started by: halo98
1 Replies
Login or Register to Ask a Question