Sponsored Content
Top Forums UNIX for Advanced & Expert Users How to determine if a File is Open? Post 14465 by aniruddha on Thursday 31st of January 2002 08:59:44 PM
Old 01-31-2002
According to me this is much more easy in C.

Here is a way to find out :-

You can use fwrite function to write data into file. Before using fwrite function use fcntl and check whether the file is locked by other thread/program.

For more information refer to the man pages of fcntl & fwrite.

Aniruddha
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to determine if a file is ASCII?

I'm writing a script that takes a filename as an argument, which determines the "file type" of the file. I want to know if there is any command I can use to determine if a file is ASCII type, thanks all for giving a help. (11 Replies)
Discussion started by: popo
11 Replies

2. UNIX for Dummies Questions & Answers

determine the size of a file???

Hello, Can someone please tell me which command to use to determine the size of a file? When I log in to my shell account, I do this $>% ls -als total 632 8 -rw-r--r-- 1 user01 devgrp1 1558 Jul 30 23:25 .kshrc What is "1158"? Bytes? Kilobytes? I apologize if my... (8 Replies)
Discussion started by: alan
8 Replies

3. Shell Programming and Scripting

determine file type with perl

Hello i will like to know please how can i determine file type inside perl script not using the unix "file" program Thanks allot (1 Reply)
Discussion started by: umen
1 Replies

4. Shell Programming and Scripting

determine owner of a file

Hello, I am on a mission to determine the user of file. I have used the ls -l command but it displays permission, link, user, group, etc, but I just want to display just the name of user of a specified file. Many thanks (4 Replies)
Discussion started by: unibboy
4 Replies

5. UNIX for Advanced & Expert Users

How to determine if a file is done copying

I have a file repository in a directory where files are copied into it by ftp or samba. Some of the ftp transfers can be slow, and some of the files can be fairly large. The files are not being used for anything in this directory other than being taken out of the directory and used by the... (2 Replies)
Discussion started by: husker_ricky
2 Replies

6. Shell Programming and Scripting

How to Determine the file owner's username

I've read the following post here and I get no output from the command. I've tried changing the '$3' to $5, 7, 10...and still nothing. Ultimately what I'd like to is determine who owns the file and rename it to file_name_$USERNAME. $ uname -a SunOS sun001 5.10 Generic_118833-33 sun4u sparc... (3 Replies)
Discussion started by: nadeemsm
3 Replies

7. Shell Programming and Scripting

Determine BL and RL of a file

A regular ebcdic mainframe tape usually contains header information the 1st three blocks of the tape. The header information tells the computer/user more information about what is on tape. The header info is 240 bytes in length at 80 bytes each header. The 1st block/header is volume name or... (1 Reply)
Discussion started by: Linux-wannabe
1 Replies

8. Red Hat

cannot set user id: Resource temporarily unavailable (not open file/open process related)

First post, sorry to be a bother but this one has been dogging me. I have a process user (java application server) that trips a resource limit every couple weeks and need help finding what limit we're hitting. First, this is what's running: This is the error when jobs are run or the... (0 Replies)
Discussion started by: Katahdin
0 Replies

9. Shell Programming and Scripting

Determine file age in days?

I am using AIX 6.1 and would like to use a one line command to determine the age of a file in days. I would like to look at a specific file. I would like to use the command to run on a remote server (AIX 6.1) to return the age of a specific file in days. So if the file is 42 days old I would... (2 Replies)
Discussion started by: oldman2
2 Replies

10. Shell Programming and Scripting

How to determine if there's a file in directory!

Hi All, I'm just wondering how can i determined if there's a file in directory and put it in a logs? dir="/home/test/" Please advise, Thanks, Use code tags, thanks. (1 Reply)
Discussion started by: nikki1200
1 Replies
FREAD(3)						     Linux Programmer's Manual							  FREAD(3)

NAME
fread, fwrite - binary stream input/output SYNOPSIS
#include <stdio.h> size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream); size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream); DESCRIPTION
The function fread() reads nmemb items of data, each size bytes long, from the stream pointed to by stream, storing them at the location given by ptr. The function fwrite() writes nmemb items of data, each size bytes long, to the stream pointed to by stream, obtaining them from the loca- tion given by ptr. For nonlocking counterparts, see unlocked_stdio(3). RETURN VALUE
On success, fread() and fwrite() return the number of items read or written. This number equals the number of bytes transferred only when size is 1. If an error occurs, or the end of the file is reached, the return value is a short item count (or zero). fread() does not distinguish between end-of-file and error, and callers must use feof(3) and ferror(3) to determine which occurred. ATTRIBUTES
For an explanation of the terms used in this section, see attributes(7). +------------------+---------------+---------+ |Interface | Attribute | Value | +------------------+---------------+---------+ |fread(), fwrite() | Thread safety | MT-Safe | +------------------+---------------+---------+ CONFORMING TO
POSIX.1-2001, POSIX.1-2008, C89. SEE ALSO
read(2), write(2), feof(3), ferror(3), unlocked_stdio(3) COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/. GNU
2015-07-23 FREAD(3)
All times are GMT -4. The time now is 11:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy