LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-11-2011, 04:07 PM   #1
ultagod
LQ Newbie
 
Registered: Dec 2010
Posts: 24

Rep: Reputation: 0
Tell when a program tries to run another program


How can you tell if a program tries to run another application? I have a binary blob that I HAVE to use for school and it requests/calls outdated software to do various things. I want to find out what software it tries to run and then make symlinks to equivalent new (newer than the 90s) software.

Thanks!
 
Old 11-11-2011, 04:46 PM   #2
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948
First, use the ldd command on the program binary to look at which dynamic libraries it is linked against. You'll need to satisfy those dependencies first, to make sure the program runs at all.

You can use the strace command to see each syscall the program makes. To run an external program or script, the program must first fork and then exec. Since forking creates a child process, you need to use the -f flag for trace -- "follow child processes too". The syscalls are output to standard error, and there will be a lot of them, so I personally like to redirect standard error to standard output, and pipe to grep.

All in all,
Code:
strace -f program 2>&1 | grep -e '^exec'
will tell you which external commands the program attempts to run. You will most likely be also interested in the output of
Code:
strace -f program 2>&1 | grep -e '^open'
which lists all the files the program opens. This will include dynamic libraries that are not linked, but are loaded on demand programmatically.
 
Old 11-11-2011, 06:55 PM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,125

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
I long ago got into the habit of always allocating an output file for strace. There's always another grep I need to run on it ...
 
  


Reply

Tags
blob, exec



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help Trying to open or run a file/program through a c++ program xskycamefalling Programming 4 01-19-2010 02:26 PM
Need help Trying to open or run a file/program through a c++ program xskycamefalling Programming 2 01-18-2010 02:51 PM
Simple C++ Program: Program Compiles But Won't Run (Segmentation Fault) violagirl23 Programming 3 01-09-2008 12:09 AM
Viewing program messages when program isn't run from command line? Locura Linux - Software 1 09-27-2003 08:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:40 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
Open Source Consulting | Domain Registration