01-21-2001
Try fstat(2) system call
You may be able to write a C program around the <B>fstat</B> system call to do the trick:
Quote:
STAT(2) System calls STAT(2)
NAME
stat, fstat, lstat - get file status
SYNOPSIS
#include <sys/stat.h>
#include <unistd.h>
int stat(const char *file_name, struct stat *buf);
int fstat(int filedes, struct stat *buf);
int lstat(const char *file_name, struct stat *buf);
DESCRIPTION
These functions return information about the specified file. You do not need any access rights to the file to get this information but you need search rights to all directories named in the path leading to the file.
10 More Discussions You Might Find Interesting
1. Solaris
Hello,
Case: If I want to run a script background and logout, which command should I use ?
1)# ./script_name &
2)# nohup script_name
3)# nohup script_name &
And any differences ?
What happens if I redirect the output to a file?
I learned somewhere that the (1) format will stop... (5 Replies)
Discussion started by: billshu
5 Replies
2. UNIX for Advanced & Expert Users
I've been asked to provide access to my system for another group of individuals to perform WebSphere and Portal tasks (stop/start specifically). I run both as root (we can debate this one later) and so know I have to figure out a way for these individuals to start and stop WebSphere and Portal as... (3 Replies)
Discussion started by: scottsl
3 Replies
3. Shell Programming and Scripting
Hi all,
I would like to know the difference between these commands
/usr/lib/fs/hsfs/mount -F /dev/lofi/1 /usr
and
mount -F hsfs /dev/lofi/1 /usr
In the first case absolute path is specified and in the next the cmd with options ,whats the differnce.
PS:am sorry ,coz this had been... (1 Reply)
Discussion started by: wrapster
1 Replies
4. Shell Programming and Scripting
Hi,
I am using HP-UNIX.
I have a requirement as below
I have to change env twice like:
cadenv <env>
cadenv <env>
ccm start -d /dbpath
ccm tar -xvf *.tar
ccm rcv ....
mv *.tar BACKUP
but after I do the first cadenv <env> , I am unable to execute any of the later commands .
... (6 Replies)
Discussion started by: charlei
6 Replies
5. Shell Programming and Scripting
I am trying to find socail security numbers in files in (and under) a specific directory and output a list of the files where they are found... the format would be with no dashes just 9 numeric characters in a row.
I have tried this:
find /DirToLookIn -exec grep '\{9\}' /dev/null {} \; >>... (1 Reply)
Discussion started by: NewSolarisAdmin
1 Replies
6. Shell Programming and Scripting
Hi gurus
I have two csv files that are outputs. The file contains data similar to
s.no,number1,number2,date1
--------------------------------
1, a123,482.29,11/28/07 13:00
2,a124,602.7,9/24/07 14:00
3,a125,266.93,10/9/07 16.48
4,a126,785.15,11/14/07 16:08
<file 2>
s.no name... (2 Replies)
Discussion started by: inkyponky
2 Replies
7. Shell Programming and Scripting
We are testing an application that accesses two tables: A and B. I am to write a script to validate the ouput files of this application.The application marks any account that has become overdue as per rule. When it runs, it updates the overdue flag in the A table according to the following rules:
... (1 Reply)
Discussion started by: inkyponky
1 Replies
8. Shell Programming and Scripting
I am suppose to make a program that cuts the extension off of a file. It uses that .ext to decide which program needs to be used to open the file. This only finds the name of the program from a list of programs I made. My problem is when it has the name of the program it needs to use, how can I... (2 Replies)
Discussion started by: dordrix
2 Replies
9. Shell Programming and Scripting
Hello!
I am a real beginner in scripting, so I am struggling with a really easy task!
I want to write a script to concatenate several text files onto each other and generate a new file. I wanted the first argument to be the name of the new file, so:
./my_script.sh new_file file1.txt... (5 Replies)
Discussion started by: malajedala
5 Replies
10. Shell Programming and Scripting
Hello all,
I have a task to patch red hat servers and some servers have a corrupted rpm database and return the error:
Error: rpmdb open failed
I know how to fix this when it occurs. What I'm hoping to do is scan a list of servers by IP and report back which server have this error.
... (6 Replies)
Discussion started by: greavette
6 Replies
STAT(2) System Calls Manual STAT(2)
NAME
stat, fstat - get file status
SYNOPSIS
#include <sys/types.h>
#include <sys/stat.h>
stat(name, buf)
char *name;
struct stat *buf;
fstat(fildes, buf)
struct stat *buf;
DESCRIPTION
Stat obtains detailed information about a named file. Fstat obtains the same information about an open file known by the file descriptor
from a successful open, creat, dup or pipe(2) call.
Name points to a null-terminated string naming a file; buf is the address of a buffer into which information is placed concerning the file.
It is unnecessary to have any permissions at all with respect to the file, but all directories leading to the file must be searchable. The
layout of the structure pointed to by buf as defined in <stat.h> is given below. St_mode is encoded according to the `#define' statements.
The mode bits 0000070 and 0000007 encode group and others permissions (see chmod(2)). The defined types, ino_t, off_t, time_t, name vari-
ous width integer values; dev_t encodes major and minor device numbers; their exact definitions are in the include file <sys/types.h> (see
types(5).
When fildes is associated with a pipe, fstat reports an ordinary file with restricted permissions. The size is the number of bytes queued
in the pipe.
st_atime is the file was last read. For reasons of efficiency, it is not set when a directory is searched, although this would be more
logical. st_mtime is the time the file was last written or created. It is not set by changes of owner, group, link count, or mode.
st_ctime is set both both by writing and changing the i-node.
SEE ALSO
ls(1), filsys(5)
DIAGNOSTICS
Zero is returned if a status is available; -1 if the file cannot be found.
ASSEMBLER
(stat = 18.)
sys stat; name; buf
(fstat = 28.)
(file descriptor in r0)
sys fstat; buf
STAT(2)