LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 05-18-2004, 05:26 PM   #1
gearoid
Member
 
Registered: Nov 2003
Location: Ireland
Distribution: Red Hat 9
Posts: 49

Rep: Reputation: 15
bash + strace = .....


hey,

this might sound bizarre but I am trying to do something and I need some help. I have downloaded the source code of both bash and strace and want to modify both to do a little playing around. I'd like to modify my bash shell so everytime a command is invoked from the command line, not only is the command executed, but it is also straced, and the result of which saved to a file...

So if I was to type
Code:
ls
it would be the equivalent of
Code:
strace -o outFileName ls
but all done automatically. As far as I can see this only requires two small (he says awaiting a backlash!!) changes to both the bash source and the strace source....

Trouble is, can anyone save me some time and tell me what / where I should be changing?? Both have multiple files, and Ks of lines of code, and I will know what to do once I am in the right place, but the trouble is finding the right place to start!! So can someone tell me what files even to be looking at???

Thanks,
Gearóid


some more info on changes I want to make (to begin with)!!....

bash - hardcode in that every command should be preceded by a call to strace also

strace - hardcode in that every invocation should have its output saved to some file

I can change the genericity of this later - but for now I'd just like to get it working!!
 
Old 05-18-2004, 06:26 PM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,523

Rep: Reputation: 365Reputation: 365Reputation: 365Reputation: 365
Some comments:
Builtin bash commands wouldn't be traced by such technique.
There is probably no need to patch the strace command itself, as if you can intercept all bash exec calls, you can also insert the options you want.
A simpler solution consist on launchin the shell itself under strace with the options "-o outFileName -ff", that will create a trace file for each subcommand you launch.
 
Old 05-18-2004, 06:27 PM   #3
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
here's a hint, for bash just grep for exec* and find where it is making calls to exec functions. and then do the exact same for strace, and right before strace calls exec open up your file and dup2 the descriptor to stdout.
 
Old 05-19-2004, 04:05 AM   #4
gearoid
Member
 
Registered: Nov 2003
Location: Ireland
Distribution: Red Hat 9
Posts: 49

Original Poster
Rep: Reputation: 15
cool, thanks for the suggestions.....
 
  


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
Usage of strace mdb84 Linux - Software 1 03-25-2005 03:13 AM
Make and strace Clementine Linux - Newbie 0 02-16-2005 08:51 PM
strace question ronopolis Linux - Software 0 01-19-2005 11:41 AM
strace useradd phoenix_fei Programming 1 11-29-2004 11:32 AM
strace for ssh williewang Programming 1 08-03-2004 09:32 PM


All times are GMT -5. The time now is 11:32 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration