The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
executing shell file in jva + tomcat jaganadh Shell Programming and Scripting 1 10-20-2007 03:58 PM
executing a binary file Terrible Shell Programming and Scripting 5 08-15-2006 09:00 AM
Find the user executing a script Chiefos UNIX for Dummies Questions & Answers 2 06-14-2006 12:40 PM
Reading file names from a file and executing the relative file from shell script anushilrai Shell Programming and Scripting 4 03-10-2006 02:25 AM
problem in executing a file i2admin UNIX for Advanced & Expert Users 2 04-30-2003 11:38 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 02-28-2006
Registered User
 

Join Date: Feb 2006
Posts: 25
How to find who is executing a file.

Suppose there is a file which is being executed by someone. Is there a way to return the username of whoever is using that file?
Reply With Quote
Forum Sponsor
  #2  
Old 02-28-2006
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,609
implement the logic within the code itself,

to call getlogin function to dump the user name (currently executing to some log file )

this will not take care of sudo users
Reply With Quote
  #3  
Old 02-28-2006
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,326
You could also use the fuser command for this.
Code:
fuser -fu /file/being/executed
Reply With Quote
  #4  
Old 02-28-2006
Registered User
 

Join Date: Feb 2006
Posts: 25
Thanks for your reply. Now all I have to do is figure out how to use getlogin()

Reply With Quote
  #5  
Old 02-28-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,269
On a lot of systems where fuser is not available lsof will work.

By execute you mean "open" by another process, right? Or are you talking about locking files -- stopping your process from opening the file when it's already open?
Reply With Quote
  #6  
Old 02-28-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,269
The answers we gave are shell commands. Why do you need getlogin()?
Reply With Quote
  #7  
Old 02-28-2006
Registered User
 

Join Date: Feb 2006
Posts: 25
I'm a complete newbie at UNIX. I have an exercise to do where I have to find the username of someone executing a script and print it to another file. I was sort of hoping for a command like finger, where you put in a script name instead of a person, to find out who is using it.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 11:28 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0