LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 06-19-2011, 10:55 AM   #1
littlebigman
Member
 
Registered: Aug 2008
Posts: 463

Rep: Reputation: 32
Question [shell] Formatting output from application?


Hello

I'm using Busybox's Hush shell on an appliance running uClinux, and would like to make sure I'm not packing shared libraries that aren't actually used by any application.

I couldn't figure out how to compile "ldd" for that environment, but I could compile "readelf" which does the job:
Quote:
find /bin -type f -print0 | xargs -0 ./readelf -d

File: /bin/myapp

Dynamic section at offset 0x7f4c contains 20 entries:
Tag Type Name/Value
0x00000001 (NEEDED) Shared library: [libgcc_s.so.1]
0x00000001 (NEEDED) Shared library: [libc.so.0]
I was wondering if it possible to format the output so that I would get something like this instead:
Quote:
/bin/myapp requires: libgcc_s.so.1, libc.so.0
Thank you.
 
Old 06-19-2011, 11:14 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,563
Blog Entries: 29

Rep: Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179
Something like:
Code:
#!/bin/bash

# Configure script environment
set -o nounset
unalias -a

# Gopher it
out=
while read _ status _ _ lib
do
    if [[ $status = '(NEEDED)' ]]; then
        lib=${lib#\[}; lib=${lib%]}
        out="$out, $lib"    
    fi
done < 'LQ-887173.txt'
echo "/bin/myapp requires:${out#,}"
Here's using it at a command prompt:
Code:
c@CW8:~/d/bin/try/LQ$ cat LQ-887173.txt
Dynamic section at offset 0x7f4c contains 20 entries:
Tag Type Name/Value
0x00000001 (NEEDED) Shared library: [libgcc_s.so.1]
0x00000001 (NEEDED) Shared library: [libc.so.0] 
c@CW8:~/d/bin/try/LQ$ ./LQ-887173.sh
/bin/myapp requires: libgcc_s.so.1, libc.so.0
 
Old 06-19-2011, 11:30 AM   #3
littlebigman
Member
 
Registered: Aug 2008
Posts: 463

Original Poster
Rep: Reputation: 32
Thanks!
 
  


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
output formatting aruna t Linux - Newbie 4 06-07-2011 05:30 AM
Output formatting . pinga123 Linux - Newbie 6 03-25-2011 04:04 AM
[SHELL] Output formatting Adrnalnrsh Programming 3 09-22-2008 11:29 AM
Formatting output krock923 Programming 2 06-07-2006 08:26 AM
Formatting output of ls doodar Linux - Newbie 29 07-29-2004 02:25 PM


All times are GMT -5. The time now is 10:25 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