How to detect files transmission at UNIX server ?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users How to detect files transmission at UNIX server ?
# 1  
Old 03-10-2016
How to detect files transmission at UNIX server ?

Dear Expert Users,

I know that Unix utility ( fuser ) is used to detect "transmission" of files from Source system to "current Linux Server".

I have scheduled this Unix script to work every 30th minutes of the hour and whenever files transmission starts at that very moment.
And, the file is picked up for transmission even though the file has not fully arrived at the "current Linux server".

This is the problem .. Kindly help ??

Code:
 # Check if the file is still being written at the Server
/bin/fuser -u ${FILE} > ${LOCAL_PATH}/process_file 2>/dev/null
PROCESS_ID=`cat ${LOCAL_PATH}/process_file`
if [ ${PROCESS_ID} ] ; then
echo "${FILE} file is still being written. Will attempt to sFTP at next iteration" >> ${LOGFILE}
echo "${FILE} file is still being written. Will attempt to sFTP at next iteration"
echo
echo "------------------------" >> ${LOGFILE}
echo
else
echo "Create batchfile for the file, ${FILE}" >> ${LOGFILE}
echo "Create batchfile for the file, ${FILE}"
. ${SCRIPT_PATH}/Create_batchfile.sh
echo


Last edited by Don Cragun; 03-10-2016 at 03:18 PM.. Reason: Remove the COLOR tags from the code.
# 2  
Old 03-10-2016
How about the sending side to put .TMP (or similar temporary extension), and when copy is over use mv command.

This would be an atomic operation on same filesystem, and your script would not need fuser at all.

What is the way 'transmission' is happening (ftp,scp or ) ?

Hope that helps
Regards
Peasant.
# 3  
Old 03-11-2016
Dear Peasant and Unix Experts,

Thank you for your message !!

Source system is a Mainframe Server and it sends files to "current Linux server". Unfortunately, we will not be able to use your suggestions here. They use CDGW software to transmit files to "current server".

And, I am using SFTP utility to further pick up the files from "current server" and send it again to "destination Linux Server". Kindly suggest any work-around or better logic in using "fuser" utility ??

Thank you.
# 4  
Old 03-11-2016
Connect direct software has built in functionality to prevent just the problem you are having.
Just modify the rule to make a mv to original name after a successful transfer, don't reinvent the wheel.

If you really want to, search the forums for fuser,lsof and pfiles examples who to find out if file is being used.

Hope that helps
Regards
# 5  
Old 03-15-2016
Dear Peasant and Unix Experts,

As I mentioned before, CD software is used to transmit files from "Source Server" to "current server". We don't have CDGW software on the "current server" where I am running this SFTP script to detect complete arrival of files using "fuser" utility.

Here is the file transmission path:
====================

"Source Sever" ---CDGW----> "Current Server" ( I used SFTP shell script ) ------> "Destination Server"

Kindly suggest any better ways to use this "fuser" utility ?

Thank you.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Do I require remote login access to a windows server to transfer files from a UNIX server

Hi All I need to transfer a file from a UNIX server to a windows server. I saw that it is possible to do this using scp command by looking at the forum listed below: ... (2 Replies)
Discussion started by: vx04
2 Replies

2. Solaris

FTP-ing files from Windows server to UNIX server

I need to transfer files from a Windows server to the Unix server and have to run some shell script on it to get the required output. Is it possible to transfer files from Windows server to unix server through any shell script? If so can you please help me with the details. Thanks in... (8 Replies)
Discussion started by: ssk250
8 Replies

3. Linux

How to detect FC lun on Server?

I have created a lun on Storage and connected it to server using fiber channel. LUN is presented on new Server . How do i check and mount this newly created LUN? (1 Reply)
Discussion started by: pinga123
1 Replies

4. UNIX for Dummies Questions & Answers

File transmission logs in UNIX

Can any one give a explaination with examples on how to understand file transmission log files in Unix for inbound and outbound traffic. (1 Reply)
Discussion started by: ITDev01
1 Replies

5. Shell Programming and Scripting

I need to move files from one UNIX server to another UNIX server.

Hi, I have two unix servers i need to move files from one server to another. For example: i have some files in Server1 and i want to run script in server2 to move files from server1. Any suggestion Thanks in advance (1 Reply)
Discussion started by: karingulanagara
1 Replies

6. Shell Programming and Scripting

Copy folder and files from unix server to linux server

We would be migrating unix solaries to Linux redhat. Basically source is unix and target is linux. i would like to copy entire file system unix/source/* to target linux/souce/* but target linux has only folder setup so what ever files copied need to be placed in the linux server with same... (8 Replies)
Discussion started by: balajikalai
8 Replies

7. Shell Programming and Scripting

Find and delete files and folders which are n days older from one unix server to another unix server

Hi All, Let me know how can i find and delete files from one unix server to another unix server which are 'N' days older. Please note that I need to delete files on remote unix server.So, probably i will need to use sftp, but question is how can i identify files and folders which are 'N'... (2 Replies)
Discussion started by: sachinkl
2 Replies

8. Programming

[C++] [Unix] TCP non-blocking. Detect server disconnection procedure over, from client.

Hello! I searched forum for similar topic, with no luck, if you know one, delete this topic, and send me private message with link please. Little background: I have a lot of clients and one serwer. Client can make multiple connections on different ports and ips, but only one can be acctive... (2 Replies)
Discussion started by: ikeban
2 Replies

9. Shell Programming and Scripting

script for to take files from FTP server to UNIX server and Unzipped that files

script for to take files from FTP server to UNIX server and Unzipped that files (1 Reply)
Discussion started by: sunilamarnadh
1 Replies

10. Programming

direct transmission of files via TCP/IP

Hi, is it possible to write files via write() to a socket and read it on the other side via read(), without going through buffers? Iif not via write() and read() are there other possibilities? thanks darkspace (5 Replies)
Discussion started by: darkspace
5 Replies
Login or Register to Ask a Question