[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Use Unix truss command to monitor all operations and activity on a file

Posted on 2004-11-02
3
Medium Priority
?
1,937 Views
Last Modified: 2013-12-26
Hi Guys,
Can someone please give me an example of how to use the truss command to monitor all operations on a particular file.

I know there is an -r switch and reference to a file descriptor - but sure if this is simply a name of a file which you have to pass in or something different


Cheers



 B Cunney

0
Comment
Question by:Barry Cunney
  • 2
3 Comments
 
LVL 14

Accepted Solution

by:
chris_calabrese earned 200 total points
ID: 12476168
A file descriptor is an integer that represents the file information in the kernel.

By convention, 0 is stdin, 1 is stdout, and 2 is stderr, so '-r 0' would mean monitoring reads to stdout.

If a program opens a fixed set of files, you can run truss against it to figure out what file descriptor ends up going to which file (by looking at the return value of the 'open' call).

If it opens different files based on user input, you'll proobably have to monitor all file descriptors since you won't know in advance which one goes with the file name you're interested in.
0
 
LVL 17

Author Comment

by:Barry Cunney
ID: 12476209
Cheers chris,
I thought that there might be some trick one could use to get the truss command just to trace operations on one file
0
 
LVL 14

Expert Comment

by:chris_calabrese
ID: 13304210
You could probably write a perl script that monitors the output of truss and figures out which lines refer to a file of a particular name...
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question