File locking (Unix/Linux) & sftp


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting File locking (Unix/Linux) & sftp
# 1  
Old 11-26-2009
File locking (Unix/Linux) & sftp

Hi all,

Can anyone help ...on how to ensure that a file is locked .

thanks & regards,
Soodoo
----------------------------------------

Problem description: -

We usually use the mv command in scripts to make sure that a file is complete and not being written to by another process.

If the mv is successful, we are confident that we can copy/ftp/process the file in confidence.

Based on tests conducted, we found that a mv on AIX will be successful even if a sftp of the file is under way.

Kindly note that we made sure that both source and destination directories were on the same file system (so that the mv would be a move and not a copy operation).

To make matters worse, a rm of a file that is being sftp'ed also worked. That is the rm command completed successfully, even before the sftp had completed, and at the end of the sftp, the file was just not there anymore!


NB: AIX version 6.1
sfp (Bitwise) 4.23
# 2  
Old 11-26-2009
You can do something like below, where the second command (sftp)will execute only if the first command (mv) is successful

Code:
mv source dest && sftp ...

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SFTP Shell Script Get & Delete && Upload & Delete

Hi All, Do you have any sample script, - auto get file from SFTP remote server and delete file in remove server after downloaded. - only download specify filename - auto upload file from local to SFTP remote server and delete local folder file after uploaded - only upload specify filename ... (3 Replies)
Discussion started by: weesiong
3 Replies

2. Red Hat

SFTP User creation in Redhat Linux/UNIX

SFTP user creation step… Create a group # groupadd sftp_users If the users doesn’t exist on system , use below command : # useradd -G sftp_users -s /sbin/nologin username # passwd username For already existing users , use below usermod command : # usermod –G... (1 Reply)
Discussion started by: taherahmed
1 Replies

3. Red Hat

Locking Down SFTP

Hi List, I'm sure this has been done before and there must be several ways to skin the cat on this topic. What I am trying to achieve is set up user accounts for use with SFTP based on the standard OpenSSH protocol. And I want to be able to lock them down so that they cannot browse outside of... (2 Replies)
Discussion started by: landossa
2 Replies

4. UNIX for Advanced & Expert Users

mandatory & record locking using client server architecture

Hi I want a program of employee database locking with mendatory & record locking using client server architecture .there are two type of clients one which has all permissions of read/write called supervisor & another can only read the file.employee data base should contain 1) name 2)ID 3)BU... (1 Reply)
Discussion started by: rluha
1 Replies

5. AIX

sftp between Unix & windows

Guys, sftp between Unix & Windows I'd like to get good software or a way to how to configure sftp between ( windows to Unix ) and ( Unix to windows ) to be automatic login between the different operating systems without asking password .. Pls assist in this regard … (3 Replies)
Discussion started by: Mr.AIX
3 Replies

6. Programming

locking mutexes, threads & semahores

What is the difference between mutex_lock and pthread_mutex_lock ? Should I use both when using binary semaphores. Also, what is the difference between using a binary semaphore and a counting semaphore where you wait on the condition variable ? (1 Reply)
Discussion started by: joey
1 Replies

7. UNIX for Advanced & Expert Users

Linux server locking up

I've been running Django on MySQL on a Linux server for about 3 months w/o any problem. Suddenly a couple days ago, the server Django began throwing errors about not being able to connect to MySQL, at which point the entire server seizes up. The Apache Web server stops serving pages and SSH seizes... (3 Replies)
Discussion started by: mongoose1
3 Replies

8. Shell Programming and Scripting

SFTP vs FTP and going UNIX to LINUX

I have automated an ftp process that FTP's files from one UNIX box to another in the following format: ftp -n -v $REMOTE_SERV << EOF user $FTP_USER $FTP_PASS cd $REMOTE_PATH put $CUR_NAME $NEW_NAME bye But how can I accomplish this SFTPing from a UNIX box to a LINUX box? I've seen... (4 Replies)
Discussion started by: TimBurke
4 Replies

9. UNIX for Dummies Questions & Answers

File Locking in Unix

Hi I would like to lock a file using korn Shell Script before coping the contents of the file. Do let me know Thanks in Advance. Senone (3 Replies)
Discussion started by: senone
3 Replies

10. UNIX Desktop Questions & Answers

what is the difference between Unix & linux, what are the advantages & disadvantages

ehe may i know what are the difference between Unix & Linux, and what are the advantages of having Unix as well as disadvantages of having Unix or if u dun mind i am dumb do pls tell me what are the advantages as well as the disadvantages of having linux as well. thanks (1 Reply)
Discussion started by: cybertechmkteo
1 Replies
Login or Register to Ask a Question