LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 11-24-2014, 01:12 AM   #1
snowhacker83
LQ Newbie
 
Registered: Nov 2014
Posts: 1

Rep: Reputation: Disabled
How to get the base package install location on Linux?


Hi All,

I am on Linux Centos OS. I understand that using "rpm -qa" gives a lot of install paths for the corresponding package. However, I need just the base package install location for the package. Is there any way/command/option in Linux to retrieve the same? My code snippet is to retrieve list of running services and the corresponding package installed is as below:-

for i in $(service --status-all | grep -v "not running" | grep -E running\|stopped | awk '{print $1}'); do packagename=$(rpm -qf /etc/init.d/$i) servicestatus=$(service --status-all | grep $i | awk '{print $NF}' | sed 's/...//g' | sed 's/.//g');

echo $tdydate, $(ip route get 8.8.8.8 | awk 'NR==1 {print $NF}'), $i, $packagename, $servicestatus > "$HOME/MyLog/running_services.csv" done

Now, I need to also get the corresponding package install location as well which is hosting the running service. Is there a way to retrieve this as well along with getting the package names. Please confirm.

Thanks in advance for extending help.

Regards.
 
Old 11-24-2014, 01:37 AM   #2
SAbhi
Member
 
Registered: Aug 2009
Location: Bangaluru, India
Distribution: CentOS 6.5, SuSE SLED/ SLES 10.2 SP2 /11.2, Fedora 11/16
Posts: 664

Rep: Reputation: 81
Quote:
Originally Posted by snowhacker83 View Post
Hi All,
for i in $(service --status-all | grep -v "not running" | grep -E running\|stopped | awk '{print $1}'); do packagename=$(rpm -qf /etc/init.d/$i) servicestatus=$(service --status-all | grep $i | awk '{print $NF}' | sed 's/...//g' | sed 's/.//g');

echo $tdydate, $(ip route get 8.8.8.8 | awk 'NR==1 {print $NF}'), $i, $packagename, $servicestatus > "$HOME/MyLog/running_services.csv" done
First try to get the install location from what you have written, i see lot of useless uses and syntax errors.

Read man page for rpm.
why using grep these many times with awk when awk alone is sufficient ?
why sed piped to sed again when sed can be used for multiple iterations without pipe ?

Please re-format your for looped line and make it working first. Then we will help you getting ahead with this.

I did saw a very similar post, which i think moderators can have a look: http://www.linuxquestions.org/questi...8/#post5269058
 
  


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
How do I install a package in a particular location without a configure script? CentOS6.3User Linux - Software 1 01-19-2013 02:07 AM
Fedora 14 Base Install is installing extra package groups? BYoungTGS Fedora 1 12-02-2010 12:47 AM
RPM package during install can or cannot define the install location? hocheetiong Linux - Software 1 09-10-2007 01:33 PM
where is install package location bobr Linux - General 2 05-17-2007 08:32 AM
LXer: Linux Standard Base plans cross-format package API LXer Syndicated Linux News 0 01-17-2007 10:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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