LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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, 05: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, 05:46 PM   #2
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943
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, 07:55 PM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,491

Rep: Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077
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


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 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 03:26 PM
Need help Trying to open or run a file/program through a c++ program xskycamefalling Programming 2 01-18-2010 03:51 PM
Simple C++ Program: Program Compiles But Won't Run (Segmentation Fault) violagirl23 Programming 3 01-09-2008 01:09 AM
Viewing program messages when program isn't run from command line? Locura Linux - Software 1 09-27-2003 09:19 AM


All times are GMT -5. The time now is 05:08 PM.

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