LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-01-2014, 10:05 PM   #1
MichaelStein
LQ Newbie
 
Registered: Apr 2014
Posts: 14

Rep: Reputation: Disabled
Creating a lgo file


Hi there Comrades,

I am new to Linux (only installed it this last Monday). I need to create a program in linux that records files that were opened, when they were opened and by who opened them (the name of the user) and when they were closed. The program will then write this information to a file (a log file).

Please can someone assist me in this task.
Many thanks in advance
 
Old 04-01-2014, 10:17 PM   #2
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 16,825

Rep: Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408
This sounds a bit like HOMEWORK
can you post what you have done so far and where you are stuck .
 
Old 04-01-2014, 11:17 PM   #3
MichaelStein
LQ Newbie
 
Registered: Apr 2014
Posts: 14

Original Poster
Rep: Reputation: Disabled
Log file

Very astute - it is homework assigned to me.
The problem is I don't know how to begin. How do I obtain information from Linux about which files were opened and when. I know how to write to a file. But how do I get the information to write to the file. Can someone direct me to sample code?
Thanks again
 
Old 04-01-2014, 11:28 PM   #4
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
Hi,

you say "program". I'm assuming what is requested is actually a shell script. If so, read on.

I think the stat command is what you are looking for. It provides all sorts of information about files. For example for the access time of a file called "file.txt" you can do:
Code:
stat --format %x file.txt
You may find that the posix time (or "seconds since Epoch") is more useful to you. Read the man page for stat to get details.

Next you'll need to learn how to use stat in a script, but presumably the course associated with this particular homework gave some instruction on shell scripting.

Evo2.
 
Old 04-02-2014, 01:09 AM   #5
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 16,825

Rep: Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408
The linux documentation project has a lot of things
like : "advanced_bash.scripting_gude.pdf"

http://www.tldp.org/LDP/abs/abs-guide.pdf
http://www.tldp.org/guides.html
 
1 members found this post helpful.
Old 04-02-2014, 07:55 AM   #6
MichaelStein
LQ Newbie
 
Registered: Apr 2014
Posts: 14

Original Poster
Rep: Reputation: Disabled
Thank you

Thank you both. Much obliged. Yes, evo2 - i meant shell script. Thank you JohnVV for your references.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
webdav: File exists error while creating new file rdo Linux - Server 3 06-20-2010 12:30 PM
open local file error when creating file descriptor hellgirl Linux - Newbie 1 09-14-2009 11:03 PM
[SOLVED] Creating an 8GB file using mmap: error calling lseek() to stretch the file kvm1983 Programming 3 07-29-2009 04:10 PM
creating a log file of users who are missing a file gd121462 Linux - Newbie 5 12-04-2008 04:54 AM
when creating a *.iso file, how to make the file size smaller? minm Linux - Newbie 8 12-26-2004 10:58 PM


All times are GMT -5. The time now is 10:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration